From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29093C77B61 for ; Thu, 13 Apr 2023 12:57:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B5EF900003; Thu, 13 Apr 2023 08:57:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8663C900002; Thu, 13 Apr 2023 08:57:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706B3900003; Thu, 13 Apr 2023 08:57:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6138F900002 for ; Thu, 13 Apr 2023 08:57:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F3D24120210 for ; Thu, 13 Apr 2023 12:57:30 +0000 (UTC) X-FDA: 80676369060.25.3AC2651 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf28.hostedemail.com (Postfix) with ESMTP id 46842C0003 for ; Thu, 13 Apr 2023 12:57:29 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=k1NjYFoM; spf=pass (imf28.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=jiaqiyan@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681390649; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fPTkUQbc2yMX8zYnhIhe3RUVaWsEC4l97mFXf0mSsn0=; b=mtCE6lYLJKA3gJQJ/FPG+ca6AebN0g+KD3m493rTxPEEkJKRCZp+3Fev9eQ6mKnj5QBo7q aZ5+AC7IOM6fJvEKQvjSrar+nc6bXGljT4LFMg9Imi51dO/uqL6KYPx5EvJCwE9ClYtKS5 vw1CSJmGuYSLOnWoXCcifbFo3lUSLQM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=k1NjYFoM; spf=pass (imf28.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=jiaqiyan@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681390649; a=rsa-sha256; cv=none; b=xBuQSAfBUoAzLflzB9GEFZwbagoNF9nC7si1nn2c/npYamLNnTq2JFjmj6UaAYhx0UanHD /OETsqgGEt+ezZ/7MiffVlaThUYSvYJowk7BqmYOJSJCQUtkGFaxoaFLGhIwullziO6wf2 t41DNNn3oQpEWidHtOvSJckffuXYzJI= Received: by mail-yb1-f178.google.com with SMTP id q5so18018408ybk.7 for ; Thu, 13 Apr 2023 05:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681390648; x=1683982648; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=fPTkUQbc2yMX8zYnhIhe3RUVaWsEC4l97mFXf0mSsn0=; b=k1NjYFoMFAG9+Rh0wRAugds8O4epb2lt8VP2Sv/+tKELjvWGyBXatSOtgcJ0SAy8Vw Yh4aXXuvVVZvvY3wrQUYKQr3NBYH0g9p1mTnPoRrisHWXzu/y0XuVT47o0Jh6M1QnRWn vWL8MRMqr0/F/naOiU66zmg8WZEpKqevWT1B+g/M+KOXvC4tDchKNk9cVTJ75toVexZu cOn7o6g9wOK1x69lZhs9W/ZjU6gD919T4uHxUemyvHnkcwFYlxHdGXZNkzO3IGLNAHSQ 7sdYlwVX7OITzLl+daSQGSbcRoGy4VamJesAU5fMYRDwTQtRb7q6M4GCPlx86KN7gMqE R83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681390648; x=1683982648; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fPTkUQbc2yMX8zYnhIhe3RUVaWsEC4l97mFXf0mSsn0=; b=CqhVqnm8PbvCOxE9QLPMCYDzU/qv8BFJFebc7sb2UB8II7PWu8DreX6wKz3htojmZU 7ju0ICcBzMc6sE4rDOl00w/8yHRa2LvdVazj+t0s5+86DVFx6fDI5ejLjf5up4dC9bSq z0Vwj+kdvU4DW+3yWzt9GPtWAR2Mv3iidrRDk0s8x11POPmANheXsJWqhZ3ivUBlqO/1 5C11/uuo5l4sFe3jU1jsMlU025rPi+rqhYvbkOCl4702lqIE3iEp8U6aMYiMeYJzfLla xUbcJeWKvPnb29DOljSV3we0bXjCjIRN78uqMFNKbLjASUHB+yj0d7/+6JsEQtZy3c4B zCMg== X-Gm-Message-State: AAQBX9fp9AJAcpodJTJqwQJ1+o1ySE5NiMEHieZKnr9Kq4JJiJ9QZWd+ odD2p8ecfqj64MUGKXSCep34mjapyOPVNYqOW6zB2w== X-Google-Smtp-Source: AKy350ZLd7FkKzPLgzdJ0pXuiAmk9gkJseXuVFmoGtTIL+694hNmJ3iryKCcyMCl5ILEK/APxIw+e0EpjjrJc0nwFKc= X-Received: by 2002:a25:30c2:0:b0:b8f:553a:ddfd with SMTP id w185-20020a2530c2000000b00b8f553addfdmr1072108ybw.5.1681390648191; Thu, 13 Apr 2023 05:57:28 -0700 (PDT) MIME-Version: 1.0 References: <20230411092741.780679-1-liushixin2@huawei.com> <20230412181350.GA22818@monkey> In-Reply-To: <20230412181350.GA22818@monkey> From: Jiaqi Yan Date: Thu, 13 Apr 2023 05:57:17 -0700 Message-ID: Subject: Re: [PATCH -next] mm: hwpoison: support recovery from HugePage copy-on-write faults To: Mike Kravetz Cc: Andrew Morton , Liu Shixin , Miaohe Lin , Muchun Song , Naoya Horiguchi , Tony Luck , linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: multipart/alternative; boundary="0000000000005126e705f937440a" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 46842C0003 X-Stat-Signature: ofpmsjzz3ixk1bneg8f9c459eusrca4z X-Rspam-User: X-HE-Tag: 1681390649-696745 X-HE-Meta: U2FsdGVkX1/VaV94fJv0HUKXdLyMYoJfQUINofWUFS3x8ew/RP1vtrPU5iF3H6lCGlCb6EAuHFVkRFBonoVz+4uZqfD288skbIUqkkTs9vVvcrnddypIdSHSC09A7IEJ1vbsk3YgK6vP6L4v243zZcj7gP6TypCfHiUYZiB0fdgc5BsUWPbixFr19SphuyacL36p8Qxg0uoqb1SbC6r5FZqyUAEBkXoOHslhKdbv+8Dw2VhkVkmam4FxQBv6bSaoNf1ffJS0V/vyYTYJpmCp3oG1pdy5RJbDk0sR5aVftgpAt96vPJATtdK54sJzs0RJAgUtI8WT89L/pk2BT1kj1agaPIJ8+/MH6DXiR2dvxLzkl9YEfZtd/xo81wsfjVUbAhMzJfnJUYOPJ2/fEi5UGnPE/ZaF1ccCorp9lP4zDj0YCPLf2AebqGEqby3tDLZT3pBOvRlRkO2tbcb0O/DgZlSCfrmTqzyvj6opZFKCs1PApm7HbFg/+frohjU0Bj41J2xWW01FGrRAO6UKKZh21ZovlX0yywhlc6NsiyE5ePA1kixCFSlaA+eLSajfBBJDUSZQTc8xyiHdi48LY0sFZsLiAD2hHGhuvA0F4kFuHulRDupMjD9u2wo/u1H0zp7DclN9/RRqlciYgmamC0ao+h/MS/li5a9uOcjMOXiOQfk4uzKjI/XJQ9r3ouVxt6WkrO2aJaFMIkoNFUHhlwEJ4OwYAxA50l1S77R1sXjqz47X+rG7La9nxjfHoErgkn+RqkA8GyGzPjuHS/zT1YguFJ0k5/yB+wlpoD5aEmj8upSDFB3vDMcqe6kcxv/wd+3J9IdqCCBi2lUFkRiIT1LnWbCJVQAZXUOu7mVqfIgT0T9hBo2aNjPdnmvOKlgFQWhlsWz4X51kNYiNzcWODQiZZeWPwUS32RpMuRJGY/QuBN4ktS5ydEXp2OSTYJIhQHNonG9ArJVVViJhsBJvolg fHDG3cUi vH5YzR0xU3YaKVZPs6EoAL3qu8SV0kw0+eIPazsYtAVw3YVyttcSV1Idii26PinweFoX/KMrx48zwQGGCStI6cR6FxAVJ/X/QWKIupzBkalG7Ak459mSqNZ0/yk6xLhsWw+LHDIknqizjQlbTzkByvxh/uX4htaT3ngjSNFHYhG3gLiT9solhr08L/HB/8PpuUjD8tVqYJIoaXo6wzcVmQTMQhzjQPY5J7E5kHm+qoMyQSjCLPQvGhDQQy+ihGQMK1L0+etOYBbUPqInIERd4epxSzD4SqTfmCFFXN6Y3qpd6cVI7j1QWbqpAGcSkzIanH+ae+jcDqBNEDLfg+TrfU4kciPomLjAcR9FswelehqOmgwoT6kkmUHypvd/oIEioTWpV3AP4GOwXKe0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0000000000005126e705f937440a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 12, 2023 at 11:14 AM Mike Kravetz wrote: > On 04/11/23 17:27, Liu Shixin wrote: > > Patch a873dfe1032a ("mm, hwpoison: try to recover from copy-on write > faults") > > introduced a new copy_user_highpage_mc() function, and fix the kernel > crash > > when the kernel is copying a normal page as the result of a copy-on-wri= te > > fault and runs into an uncorrectable error. But it doesn't work for > HugeTLB. > > Andrew asked about user-visible effects. Perhaps, a better way of > stating this in the commit message might be: > > Commit a873dfe1032a ("mm, hwpoison: try to recover from copy-on write > faults") introduced the routine copy_user_highpage_mc() to gracefully > handle copying of user pages with uncorrectable errors. Previously, > such copies would result in a kernel crash. hugetlb has separate code > paths for copy-on-write and does not benefit from the changes made in > commit a873dfe1032a. > > Modify hugetlb copy-on-write code paths to use copy_mc_user_highpage() > so that they can also gracefully handle uncorrectable errors in user > pages. This involves changing the hugetlb specific routine > ?copy_user_folio()? from type void to int so that it can return an error. > Modify the hugetlb userfaultfd code in the same way so that it can return > -EHWPOISON if it encounters an uncorrectable error. > > NOTE - There is still some churn in the series that introduces > copy_user_folio() and the name may change. > > > This is to support HugeTLB by using copy_mc_user_highpage() in > copy_subpage() > > and copy_user_gigantic_page() too. > > > > Moreover, this is also used by userfaultfd, it will return -EHWPOISON i= f > > running into an uncorrectable error. > > > > Signed-off-by: Liu Shixin > > --- > > include/linux/mm.h | 6 ++--- > > mm/hugetlb.c | 19 +++++++++++---- > > mm/memory.c | 59 +++++++++++++++++++++++++++++----------------- > > 3 files changed, 56 insertions(+), 28 deletions(-) > > Code changes look good to me. > > Acked-by: Mike Kravetz > > Related question perhaps for Tony not directly impacting this patch. > This patch touches the hugetlb clear page paths withour consequence. > > Just wondering if we can/should create something like > clear_mc_user_highpage > to address clearing pages as well? Apologies if this was previously > discussed. Tony may have better answers but allow me to chime in for this question: Memory related #MC only happens when kernel reads encounter hw uncorrectbale memory errors. Writes(clearing memory page) are =E2=80=9Csafe= =E2=80=9D to kernel, at least generating no #MC. So I don=E2=80=99t think clear_user_hig= hpage needs a #MC handled version (or even possible at all). > -- > Mike Kravetz > > --0000000000005126e705f937440a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, Apr 12, 2023 at 11:14 AM Mike Kravetz <mike.kravetz@oracle.com> wrote:<= br>
On 04/11/23 17:27, Liu Shixin wrote:
> Patch a873dfe1032a ("mm, hwpoison: try to recover from copy-on wr= ite faults")
> introduced a new copy_user_highpage_mc() function, and fix the kernel = crash
> when the kernel is copying a normal page as the result of a copy-on-wr= ite
> fault and runs into an uncorrectable error. But it doesn't work fo= r HugeTLB.

Andrew asked about user-visible effects.=C2=A0 Perhaps, a better way of
stating this in the commit message might be:

Commit a873dfe1032a ("mm, hwpoison: try to recover from copy-on write<= br> faults") introduced the routine copy_user_highpage_mc() to gracefully<= br> handle copying of user pages with uncorrectable errors.=C2=A0 Previously, such copies would result in a kernel crash.=C2=A0 hugetlb has separate code=
paths for copy-on-write and does not benefit from the changes made in
commit a873dfe1032a.

Modify hugetlb copy-on-write code paths to use copy_mc_user_highpage()
so that they can also gracefully handle uncorrectable errors in user
pages.=C2=A0 This involves changing the hugetlb specific routine
?copy_user_folio()? from type void to int so that it can return an error. Modify the hugetlb userfaultfd code in the same way so that it can return -EHWPOISON if it encounters an uncorrectable error.

NOTE - There is still some churn in the series that introduces
copy_user_folio() and the name may change.

> This is to support HugeTLB by using copy_mc_user_highpage() in copy_su= bpage()
> and copy_user_gigantic_page() too.
>
> Moreover, this is also used by userfaultfd, it will return -EHWPOISON = if
> running into an uncorrectable error.
>
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
>=C2=A0 include/linux/mm.h |=C2=A0 6 ++---
>=C2=A0 mm/hugetlb.c=C2=A0 =C2=A0 =C2=A0 =C2=A0| 19 +++++++++++----
>=C2=A0 mm/memory.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 59 ++++++++++++++++++++= +++++++++-----------------
>=C2=A0 3 files changed, 56 insertions(+), 28 deletions(-)

Code changes look good to me.

Acked-by: Mike Kravetz <mike.kravetz@oracle.com>

Related question perhaps for Tony not directly impacting this patch.
This patch touches the hugetlb clear page paths withour consequence.

Just wondering if we can/should create something like clear_mc_user_highpag= e
to address clearing pages as well?=C2=A0 Apologies if this was previously discussed.

Tony m= ay have better answers but allow me to chime in for this question: Memory r= elated #MC only happens when kernel reads encounter hw uncorrectbale memory= errors. Writes(clearing memory page) are =E2=80=9Csafe=E2=80=9D to kernel,= at least generating no #MC. So I don=E2=80=99t think clear_user_highpage n= eeds a #MC handled version (or even possible at all).


--
Mike Kravetz

--0000000000005126e705f937440a--