Message ID | 20230406230127.716716-1-jane.chu@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1358926vqo; Thu, 6 Apr 2023 16:12:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YUCLH4kmSQ18u2/mrcGE997MTumjclTg+DeubZy9N6A+uvPs6wF8juHA/X9JgJdDHy1s2y X-Received: by 2002:a17:902:fb44:b0:1a1:b440:377d with SMTP id lf4-20020a170902fb4400b001a1b440377dmr671711plb.2.1680822758398; Thu, 06 Apr 2023 16:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680822758; cv=none; d=google.com; s=arc-20160816; b=sMxBF9r10LcCViC26Dre6sHUbTU3MS4Rp9c2qFAkILzUwE0OTFKIO92OxgCqNwFxdc JcymUtdVdsUek2gVL3WGTaaWFHWtwwbiHAFsph0NoLWyDMAFQ2BP+dCd85bcHVV+pX6P ZY25JOues1n54XaUpjwNAAlRA8H/S08jx3Cw0DWK8uPublUivA2pOKui9nlPb8H9xB8b PhtZDqnFJc30WXXr6JaPQQet2X0mYN2Yq9kU6x6/aguJkaX9eJ04z6hP5XCx+Rquu04Z Isj5CuE9VpMgPEQ4rF+QlX5rmnJNNlwuKgKWwuoJYmYuHZEkuihcrkgwiUOwt73RxCUE 5gFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature; bh=QYrH7mgx9goRgDjZnqA63zjuyrkGvo4AdK4TauLX8A8=; b=MDzvIwipV4idkZTIe/u4bzb2XTxkTYybrdE9B5K1Rah8dAufbVDm5HF5WJp3A+acV6 ViM9bFVfN1aA1qLxTjWYf6LJ+0SVvM0N/zC6D10BQX18qcfgHfp2iM+I7vIquTf44m7p SzIhoJJaX/rLgcJv/OmrtpdlIN0EzY5aKOnucpDQnZVjwQpBg5qfkgdsPgQpaRbLDjGb F5FHY8/y0DdMNLmwgNicfYn5dMYR7ZeEVgb0i7bh1+mpFOCRznhqI2tEyExq/fsUTsZ7 KWZIJGxMbfX1Apte0ZnX1k0fkYSlE7lI1xDZcMKCrWtoMiKsJ/nx0Dzwu0HQGJyvdn7X +dDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=yh3NYsUN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a17090322c700b0019cec50618csi2867750plg.159.2023.04.06.16.12.25; Thu, 06 Apr 2023 16:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=yh3NYsUN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239410AbjDFXCB (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 6 Apr 2023 19:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjDFXB7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 6 Apr 2023 19:01:59 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18602A3; Thu, 6 Apr 2023 16:01:58 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336MRxvo013858; Thu, 6 Apr 2023 23:01:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id; s=corp-2022-7-12; bh=QYrH7mgx9goRgDjZnqA63zjuyrkGvo4AdK4TauLX8A8=; b=yh3NYsUNBCzx4Q8vjpGLqFRWbYQ5hFX50BLsXK9/Uu9UVlREaO9zmtHBpd62mWwKNsGP c9ApWwfJzcG1EmXGV2OkMBQTroGMtt/3wITD98lNZsn4LzO56DPy47qtUQ5eVtoCI3sN suG7bmYEEwyu951tHNqHTl9a4+uzNVZYlAWSjrtf4qVy2GPYXVQcN/7gO3o2CckN2+M/ luIG0rr/RzAd3czsh9hufvo5Yl4UKHP88qJtCUajemi7yt745+beXEH6r+Gkrs01rH0J GtRFZAYMALVSDs4oJ0j6t9C/0P0lNkS9mQH21ToI78pK95dP0nxrHVYaBAvYD8LBR2ZS 7w== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3ppbd442q2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 06 Apr 2023 23:01:34 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 336KlH5P009090; Thu, 6 Apr 2023 23:01:33 GMT Received: from brm-x62-16.us.oracle.com (brm-x62-16.us.oracle.com [10.80.150.37]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3ppt3kqpt4-1; Thu, 06 Apr 2023 23:01:33 +0000 From: Jane Chu <jane.chu@oracle.com> To: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, willy@infradead.org, viro@zeniv.linux.org.uk, brauner@kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2] dax: enable dax fault handler to report VM_FAULT_HWPOISON Date: Thu, 6 Apr 2023 17:01:27 -0600 Message-Id: <20230406230127.716716-1-jane.chu@oracle.com> X-Mailer: git-send-email 2.18.4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_12,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060200 X-Proofpoint-ORIG-GUID: nMaMTcFEj8i5h-91hzIIjnDqo_X59Jn0 X-Proofpoint-GUID: nMaMTcFEj8i5h-91hzIIjnDqo_X59Jn0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762450731082128720?= X-GMAIL-MSGID: =?utf-8?q?1762470404489579475?= |
Series |
[v2] dax: enable dax fault handler to report VM_FAULT_HWPOISON
|
|
Commit Message
Jane Chu
April 6, 2023, 11:01 p.m. UTC
When dax fault handler fails to provision the fault page due to
hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered
to userspace with .si_code BUS_ADRERR. Channel dax backend driver's
detection on hwpoison to the filesystem to provide the precise reason
for the fault.
Signed-off-by: Jane Chu <jane.chu@oracle.com>
---
drivers/nvdimm/pmem.c | 2 +-
fs/dax.c | 2 +-
include/linux/mm.h | 2 ++
3 files changed, 4 insertions(+), 2 deletions(-)
Comments
Ping, any comment? thanks, -jane On 4/6/2023 4:01 PM, Jane Chu wrote: > When dax fault handler fails to provision the fault page due to > hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered > to userspace with .si_code BUS_ADRERR. Channel dax backend driver's > detection on hwpoison to the filesystem to provide the precise reason > for the fault. > > Signed-off-by: Jane Chu <jane.chu@oracle.com> > --- > drivers/nvdimm/pmem.c | 2 +- > fs/dax.c | 2 +- > include/linux/mm.h | 2 ++ > 3 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > index ceea55f621cc..46e094e56159 100644 > --- a/drivers/nvdimm/pmem.c > +++ b/drivers/nvdimm/pmem.c > @@ -260,7 +260,7 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, > long actual_nr; > > if (mode != DAX_RECOVERY_WRITE) > - return -EIO; > + return -EHWPOISON; > > /* > * Set the recovery stride is set to kernel page size because > diff --git a/fs/dax.c b/fs/dax.c > index 3e457a16c7d1..c93191cd4802 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1456,7 +1456,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, > > map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), > DAX_ACCESS, &kaddr, NULL); > - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { > + if (map_len == -EHWPOISON && iov_iter_rw(iter) == WRITE) { > map_len = dax_direct_access(dax_dev, pgoff, > PHYS_PFN(size), DAX_RECOVERY_WRITE, > &kaddr, NULL); > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 1f79667824eb..e4c974587659 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3217,6 +3217,8 @@ static inline vm_fault_t vmf_error(int err) > { > if (err == -ENOMEM) > return VM_FAULT_OOM; > + else if (err == -EHWPOISON) > + return VM_FAULT_HWPOISON; > return VM_FAULT_SIGBUS; > } >
Jane Chu wrote: > When dax fault handler fails to provision the fault page due to > hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered > to userspace with .si_code BUS_ADRERR. Channel dax backend driver's > detection on hwpoison to the filesystem to provide the precise reason > for the fault. It's not yet clear to me by this description why this is an improvement or will not cause other confusion. In this case the reason for the SIGBUS is because the driver wants to prevent access to poison, not that the CPU consumed poison. Can you clarify what is lost by *not* making this change? > > Signed-off-by: Jane Chu <jane.chu@oracle.com> > --- > drivers/nvdimm/pmem.c | 2 +- > fs/dax.c | 2 +- > include/linux/mm.h | 2 ++ > 3 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c > index ceea55f621cc..46e094e56159 100644 > --- a/drivers/nvdimm/pmem.c > +++ b/drivers/nvdimm/pmem.c > @@ -260,7 +260,7 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, > long actual_nr; > > if (mode != DAX_RECOVERY_WRITE) > - return -EIO; > + return -EHWPOISON; > > /* > * Set the recovery stride is set to kernel page size because > diff --git a/fs/dax.c b/fs/dax.c > index 3e457a16c7d1..c93191cd4802 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1456,7 +1456,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, > > map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), > DAX_ACCESS, &kaddr, NULL); > - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { > + if (map_len == -EHWPOISON && iov_iter_rw(iter) == WRITE) { > map_len = dax_direct_access(dax_dev, pgoff, > PHYS_PFN(size), DAX_RECOVERY_WRITE, > &kaddr, NULL); This change results in EHWPOISON leaking to usersapce in the case of read(2), that's not a return code that block I/O applications have ever had to contend with before. Just as badblocks cause EIO to be returned, so should poisoned cachelines for pmem. > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 1f79667824eb..e4c974587659 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3217,6 +3217,8 @@ static inline vm_fault_t vmf_error(int err) > { > if (err == -ENOMEM) > return VM_FAULT_OOM; > + else if (err == -EHWPOISON) > + return VM_FAULT_HWPOISON; > return VM_FAULT_SIGBUS; > } > > -- > 2.18.4 > >
Hi, Dan, On 4/27/2023 2:36 PM, Dan Williams wrote: > Jane Chu wrote: >> When dax fault handler fails to provision the fault page due to >> hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered >> to userspace with .si_code BUS_ADRERR. Channel dax backend driver's >> detection on hwpoison to the filesystem to provide the precise reason >> for the fault. > > It's not yet clear to me by this description why this is an improvement > or will not cause other confusion. In this case the reason for the > SIGBUS is because the driver wants to prevent access to poison, not that > the CPU consumed poison. Can you clarify what is lost by *not* making > this change? Elsewhere when hwpoison is detected by page fault handler and helpers as the direct cause to failure, VM_FAULT_HWPOISON or VM_FAULT_HWPOISON_LARGE is flagged to ensure accurate SIGBUS payload is produced, such as wp_page_copy() in COW case, do_swap_page() from handle_pte_fault(), hugetlb_fault() in hugetlb page fault case where the huge fault size would be indicated in the payload. But dax fault has been an exception in that the SIGBUS payload does not indicate poison, nor fault size. I don't see why it should be though, recall an internal user expressing confusion regarding the different SIGBUS payloads. > >> >> Signed-off-by: Jane Chu <jane.chu@oracle.com> >> --- >> drivers/nvdimm/pmem.c | 2 +- >> fs/dax.c | 2 +- >> include/linux/mm.h | 2 ++ >> 3 files changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c >> index ceea55f621cc..46e094e56159 100644 >> --- a/drivers/nvdimm/pmem.c >> +++ b/drivers/nvdimm/pmem.c >> @@ -260,7 +260,7 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, >> long actual_nr; >> >> if (mode != DAX_RECOVERY_WRITE) >> - return -EIO; >> + return -EHWPOISON; >> >> /* >> * Set the recovery stride is set to kernel page size because >> diff --git a/fs/dax.c b/fs/dax.c >> index 3e457a16c7d1..c93191cd4802 100644 >> --- a/fs/dax.c >> +++ b/fs/dax.c >> @@ -1456,7 +1456,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, >> >> map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), >> DAX_ACCESS, &kaddr, NULL); >> - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { >> + if (map_len == -EHWPOISON && iov_iter_rw(iter) == WRITE) { >> map_len = dax_direct_access(dax_dev, pgoff, >> PHYS_PFN(size), DAX_RECOVERY_WRITE, >> &kaddr, NULL); > > This change results in EHWPOISON leaking to usersapce in the case of > read(2), that's not a return code that block I/O applications have ever > had to contend with before. Just as badblocks cause EIO to be returned, > so should poisoned cachelines for pmem. The read(2) man page (https://man.archlinux.org/man/read.2) says "On error, -1 is returned, and errno is set to indicate the error. In this case, it is left unspecified whether the file position (if any) changes." If read(2) users haven't dealt with EHWPOISON before, they may discover that with pmem backed dax file, it's possible. Thanks! -jane
Hi, Dan, On 4/27/2023 2:36 PM, Dan Williams wrote: > Jane Chu wrote: >> When dax fault handler fails to provision the fault page due to >> hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered >> to userspace with .si_code BUS_ADRERR. Channel dax backend driver's >> detection on hwpoison to the filesystem to provide the precise reason >> for the fault. > > It's not yet clear to me by this description why this is an improvement > or will not cause other confusion. In this case the reason for the > SIGBUS is because the driver wants to prevent access to poison, not that > the CPU consumed poison. Can you clarify what is lost by *not* making > this change? Elsewhere when hwpoison is detected by page fault handler and helpers as the direct cause to failure, VM_FAULT_HWPOISON or VM_FAULT_HWPOISON_LARGE is flagged to ensure accurate SIGBUS payload is produced, such as wp_page_copy() in COW case, do_swap_page() from handle_pte_fault(), hugetlb_fault() in hugetlb page fault case where the huge fault size would be indicated in the payload. But dax fault has been an exception in that the SIGBUS payload does not indicate poison, nor fault size. I don't see why it should be though, recall an internal user expressing confusion regarding the different SIGBUS payloads. > >> >> Signed-off-by: Jane Chu <jane.chu@oracle.com> >> --- >> drivers/nvdimm/pmem.c | 2 +- >> fs/dax.c | 2 +- >> include/linux/mm.h | 2 ++ >> 3 files changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c >> index ceea55f621cc..46e094e56159 100644 >> --- a/drivers/nvdimm/pmem.c >> +++ b/drivers/nvdimm/pmem.c >> @@ -260,7 +260,7 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, >> long actual_nr; >> >> if (mode != DAX_RECOVERY_WRITE) >> - return -EIO; >> + return -EHWPOISON; >> >> /* >> * Set the recovery stride is set to kernel page size because >> diff --git a/fs/dax.c b/fs/dax.c >> index 3e457a16c7d1..c93191cd4802 100644 >> --- a/fs/dax.c >> +++ b/fs/dax.c >> @@ -1456,7 +1456,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, >> >> map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), >> DAX_ACCESS, &kaddr, NULL); >> - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { >> + if (map_len == -EHWPOISON && iov_iter_rw(iter) == WRITE) { >> map_len = dax_direct_access(dax_dev, pgoff, >> PHYS_PFN(size), DAX_RECOVERY_WRITE, >> &kaddr, NULL); > > This change results in EHWPOISON leaking to usersapce in the case of > read(2), that's not a return code that block I/O applications have ever > had to contend with before. Just as badblocks cause EIO to be returned, > so should poisoned cachelines for pmem. The read(2) man page (https://man.archlinux.org/man/read.2) says "On error, -1 is returned, and errno is set to indicate the error. In this case, it is left unspecified whether the file position (if any) changes." If users haven't dealt with EHWPOISON before, they may discover that with pmem backed dax, it's possible. Thanks! -jane
On Thu, Apr 27, 2023 at 04:36:58PM -0700, Jane Chu wrote: > > This change results in EHWPOISON leaking to usersapce in the case of > > read(2), that's not a return code that block I/O applications have ever > > had to contend with before. Just as badblocks cause EIO to be returned, > > so should poisoned cachelines for pmem. > > The read(2) man page (https://man.archlinux.org/man/read.2) says > "On error, -1 is returned, and errno is set to indicate the error. In this > case, it is left unspecified whether the file position (if any) changes." > > If read(2) users haven't dealt with EHWPOISON before, they may discover that > with pmem backed dax file, it's possible. I don't think they should. While syscalls are allowed to return errnos other than the ones listed in POSIX, I don't think this is a worthwhile difference. We should be abstracting from the user that this is pmem rather than spinning rust or nand. So we should convert the EHWPOISON to EIO as Dan suggests.
On 4/27/2023 4:48 PM, Matthew Wilcox wrote: > On Thu, Apr 27, 2023 at 04:36:58PM -0700, Jane Chu wrote: >>> This change results in EHWPOISON leaking to usersapce in the case of >>> read(2), that's not a return code that block I/O applications have ever >>> had to contend with before. Just as badblocks cause EIO to be returned, >>> so should poisoned cachelines for pmem. >> >> The read(2) man page (https://man.archlinux.org/man/read.2) says >> "On error, -1 is returned, and errno is set to indicate the error. In this >> case, it is left unspecified whether the file position (if any) changes." >> >> If read(2) users haven't dealt with EHWPOISON before, they may discover that >> with pmem backed dax file, it's possible. > > I don't think they should. While syscalls are allowed to return errnos > other than the ones listed in POSIX, I don't think this is a worthwhile > difference. We should be abstracting from the user that this is pmem > rather than spinning rust or nand. So we should convert the EHWPOISON > to EIO as Dan suggests. Got it, I'll add errno conversion in the respin. thanks, -jane
Jane Chu wrote: > Hi, Dan, > > On 4/27/2023 2:36 PM, Dan Williams wrote: > > Jane Chu wrote: > >> When dax fault handler fails to provision the fault page due to > >> hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered > >> to userspace with .si_code BUS_ADRERR. Channel dax backend driver's > >> detection on hwpoison to the filesystem to provide the precise reason > >> for the fault. > > > > It's not yet clear to me by this description why this is an improvement > > or will not cause other confusion. In this case the reason for the > > SIGBUS is because the driver wants to prevent access to poison, not that > > the CPU consumed poison. Can you clarify what is lost by *not* making > > this change? > > Elsewhere when hwpoison is detected by page fault handler and helpers as > the direct cause to failure, VM_FAULT_HWPOISON or > VM_FAULT_HWPOISON_LARGE is flagged to ensure accurate SIGBUS payload is > produced, such as wp_page_copy() in COW case, do_swap_page() from > handle_pte_fault(), hugetlb_fault() in hugetlb page fault case where the > huge fault size would be indicated in the payload. > > But dax fault has been an exception in that the SIGBUS payload does not > indicate poison, nor fault size. I don't see why it should be though, > recall an internal user expressing confusion regarding the different > SIGBUS payloads. ...but again this the typical behavior with block devices. If a block device has badblock that causes page cache page not to be populated that's a SIGBUS without hwpoison information. If the page cache is properly populated and then the CPU consumes poison that's a SIGBUS with the additional hwpoison information. Applications should have a consistent error response regardless of pmem or dax.
On Thu, Apr 27, 2023 at 06:35:57PM -0700, Dan Williams wrote: > Jane Chu wrote: > > Hi, Dan, > > > > On 4/27/2023 2:36 PM, Dan Williams wrote: > > > Jane Chu wrote: > > >> When dax fault handler fails to provision the fault page due to > > >> hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered > > >> to userspace with .si_code BUS_ADRERR. Channel dax backend driver's > > >> detection on hwpoison to the filesystem to provide the precise reason > > >> for the fault. > > > > > > It's not yet clear to me by this description why this is an improvement > > > or will not cause other confusion. In this case the reason for the > > > SIGBUS is because the driver wants to prevent access to poison, not that > > > the CPU consumed poison. Can you clarify what is lost by *not* making > > > this change? > > > > Elsewhere when hwpoison is detected by page fault handler and helpers as > > the direct cause to failure, VM_FAULT_HWPOISON or > > VM_FAULT_HWPOISON_LARGE is flagged to ensure accurate SIGBUS payload is > > produced, such as wp_page_copy() in COW case, do_swap_page() from > > handle_pte_fault(), hugetlb_fault() in hugetlb page fault case where the > > huge fault size would be indicated in the payload. > > > > But dax fault has been an exception in that the SIGBUS payload does not > > indicate poison, nor fault size. I don't see why it should be though, > > recall an internal user expressing confusion regarding the different > > SIGBUS payloads. > > ...but again this the typical behavior with block devices. If a block > device has badblock that causes page cache page not to be populated > that's a SIGBUS without hwpoison information. If the page cache is > properly populated and then the CPU consumes poison that's a SIGBUS with > the additional hwpoison information. I'm not sure that's true when we mmap(). Yes, it's not consistent with -EIO from read(), but we have additional information here, and it's worth providing it. You can think of it as *in this instance*, the error is found "in the page cache", because that's effectively where the error is from the point of view of the application?
Matthew Wilcox wrote: > On Thu, Apr 27, 2023 at 06:35:57PM -0700, Dan Williams wrote: > > Jane Chu wrote: > > > Hi, Dan, > > > > > > On 4/27/2023 2:36 PM, Dan Williams wrote: > > > > Jane Chu wrote: > > > >> When dax fault handler fails to provision the fault page due to > > > >> hwpoison, it returns VM_FAULT_SIGBUS which lead to a sigbus delivered > > > >> to userspace with .si_code BUS_ADRERR. Channel dax backend driver's > > > >> detection on hwpoison to the filesystem to provide the precise reason > > > >> for the fault. > > > > > > > > It's not yet clear to me by this description why this is an improvement > > > > or will not cause other confusion. In this case the reason for the > > > > SIGBUS is because the driver wants to prevent access to poison, not that > > > > the CPU consumed poison. Can you clarify what is lost by *not* making > > > > this change? > > > > > > Elsewhere when hwpoison is detected by page fault handler and helpers as > > > the direct cause to failure, VM_FAULT_HWPOISON or > > > VM_FAULT_HWPOISON_LARGE is flagged to ensure accurate SIGBUS payload is > > > produced, such as wp_page_copy() in COW case, do_swap_page() from > > > handle_pte_fault(), hugetlb_fault() in hugetlb page fault case where the > > > huge fault size would be indicated in the payload. > > > > > > But dax fault has been an exception in that the SIGBUS payload does not > > > indicate poison, nor fault size. I don't see why it should be though, > > > recall an internal user expressing confusion regarding the different > > > SIGBUS payloads. > > > > ...but again this the typical behavior with block devices. If a block > > device has badblock that causes page cache page not to be populated > > that's a SIGBUS without hwpoison information. If the page cache is > > properly populated and then the CPU consumes poison that's a SIGBUS with > > the additional hwpoison information. > > I'm not sure that's true when we mmap(). Yes, it's not consistent with > -EIO from read(), but we have additional information here, and it's worth > providing it. You can think of it as *in this instance*, the error is > found "in the page cache", because that's effectively where the error > is from the point of view of the application? It's true there is additional information, and applications mostly cannot tell the difference between fault on failure to populate and fault on access after populate. So while it is inconsistent with what happens for typical page cache, but you're right there's no downside to conveying the extra information here.
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index ceea55f621cc..46e094e56159 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -260,7 +260,7 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, long actual_nr; if (mode != DAX_RECOVERY_WRITE) - return -EIO; + return -EHWPOISON; /* * Set the recovery stride is set to kernel page size because diff --git a/fs/dax.c b/fs/dax.c index 3e457a16c7d1..c93191cd4802 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1456,7 +1456,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), DAX_ACCESS, &kaddr, NULL); - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { + if (map_len == -EHWPOISON && iov_iter_rw(iter) == WRITE) { map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), DAX_RECOVERY_WRITE, &kaddr, NULL); diff --git a/include/linux/mm.h b/include/linux/mm.h index 1f79667824eb..e4c974587659 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3217,6 +3217,8 @@ static inline vm_fault_t vmf_error(int err) { if (err == -ENOMEM) return VM_FAULT_OOM; + else if (err == -EHWPOISON) + return VM_FAULT_HWPOISON; return VM_FAULT_SIGBUS; }