From: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
Liu Shixin <liushixin2@huawei.com>,
Yang Shi <shy828301@gmail.com>,
Oscar Salvador <osalvador@suse.de>,
Muchun Song <songmuchun@bytedance.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [mm-unstable PATCH v6 3/8] mm, hwpoison, hugetlb: support saving mechanism of raw error pages
Date: Wed, 13 Jul 2022 11:54:48 +0000 [thread overview]
Message-ID: <20220713115447.GB2824071@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <0ba226e6-c297-d87d-f74e-9036a6121072@huawei.com>
On Wed, Jul 13, 2022 at 12:51:30PM +0800, Miaohe Lin wrote:
> On 2022/7/12 11:28, Naoya Horiguchi wrote:
> > From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> >
> > When handling memory error on a hugetlb page, the error handler tries to
> > dissolve and turn it into 4kB pages. If it's successfully dissolved,
> > PageHWPoison flag is moved to the raw error page, so that's all right.
> > However, dissolve sometimes fails, then the error page is left as
> > hwpoisoned hugepage. It's useful if we can retry to dissolve it to save
> > healthy pages, but that's not possible now because the information about
> > where the raw error pages is lost.
> >
> > Use the private field of a few tail pages to keep that information. The
> > code path of shrinking hugepage pool uses this info to try delayed dissolve.
> > In order to remember multiple errors in a hugepage, a singly-linked list
> > originated from SUBPAGE_INDEX_HWPOISON-th tail page is constructed. Only
> > simple operations (adding an entry or clearing all) are required and the
> > list is assumed not to be very long, so this simple data structure should
> > be enough.
> >
> > If we failed to save raw error info, the hwpoison hugepage has errors on
> > unknown subpage, then this new saving mechanism does not work any more,
> > so disable saving new raw error info and freeing hwpoison hugepages.
> >
> > Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> > Reported-by: kernel test robot <lkp@intel.com>
>
> This patch looks good to me with some nits below.
>
> > ---
> ...
> > +static int hugetlb_set_page_hwpoison(struct page *hpage, struct page *page)
> > +{
> > + struct llist_head *head;
> > + struct raw_hwp_page *raw_hwp;
> > + struct llist_node *t, *tnode;
> > + int ret = TestSetPageHWPoison(hpage) ? -EHWPOISON : 0;
> > +
> > + /*
> > + * Once the hwpoison hugepage has lost reliable raw error info,
> > + * there is little meaning to keep additional error info precisely,
> > + * so skip to add additional raw error info.
> > + */
> > + if (HPageRawHwpUnreliable(hpage))
> > + return -EHWPOISON;
> > + head = raw_hwp_list_head(hpage);
> > + llist_for_each_safe(tnode, t, head->first) {
> > + struct raw_hwp_page *p = container_of(tnode, struct raw_hwp_page, node);
> > +
> > + if (p->page == page)
> > + return -EHWPOISON;
> > + }
> > +
> > + raw_hwp = kmalloc(sizeof(struct raw_hwp_page), GFP_ATOMIC);
> > + if (raw_hwp) {
> > + raw_hwp->page = page;
> > + llist_add(&raw_hwp->node, head);
> > + /* the first error event will be counted in action_result(). */
> > + if (ret)
> > + num_poisoned_pages_inc();
> > + } else {
> > + /*
> > + * Failed to save raw error info. We no longer trace all
> > + * hwpoisoned subpages, and we need refuse to free/dissolve
> > + * this hwpoisoned hugepage.
> > + */
> > + SetHPageRawHwpUnreliable(hpage);
>
> IMHO, when HPageRawHwpUnreliable is set, we can simply free the raw_hwp_list here
> to save some memory as they're not used anymore.
Yes, that's possible. Let's do this.
>
> > + }
> > + return ret;
> > +}
> > +
> > +void hugetlb_clear_page_hwpoison(struct page *hpage)
> > +{
> > + struct llist_head *head;
> > + struct llist_node *t, *tnode;
> > +
> > + if (!HPageRawHwpUnreliable(hpage))
> > + ClearPageHWPoison(hpage);
> > + head = raw_hwp_list_head(hpage);
> > + llist_for_each_safe(tnode, t, head->first) {
> > + struct raw_hwp_page *p = container_of(tnode, struct raw_hwp_page, node);
> > +
> > + SetPageHWPoison(p->page);
> > + kfree(p);
> > + }
> > + llist_del_all(head);
> > +}
> > +
> > /*
> > * Called from hugetlb code with hugetlb_lock held.
> > *
> > @@ -1698,7 +1771,7 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
> > goto out;
> > }
> >
> > - if (TestSetPageHWPoison(head)) {
> > + if (hugetlb_set_page_hwpoison(head, page)) {
> > ret = -EHWPOISON;
> > goto out;
> > }
> > @@ -1710,7 +1783,6 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
> > return ret;
> > }
> >
> > -#ifdef CONFIG_HUGETLB_PAGE
> > /*
> > * Taking refcount of hugetlb pages needs extra care about race conditions
> > * with basic operations like hugepage allocation/free/demotion.
> > @@ -1751,7 +1823,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
> > lock_page(head);
> >
> > if (hwpoison_filter(p)) {
> > - ClearPageHWPoison(head);
> > + hugetlb_clear_page_hwpoison(head);
>
> If the code reach here, the hugetlb page should be poisoned first time or it will return
> in above "res == -EHWPOISON" case. So ClearPageHWPoison should be fine here. But this change
> will do the same thing while making the code more consistent. So it should be fine. :)
Right, this change is for consistency.
>
> > res = -EOPNOTSUPP;
> > goto out;
> > }
> >
>
> Anyway, for what it worth,
>
> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
>
> Thanks!
Thank you.
- Naoya Horiguchi
next prev parent reply other threads:[~2022-07-13 11:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 3:28 [mm-unstable PATCH v6 0/8] mm, hwpoison: enable 1GB hugepage support (v6) Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 1/8] mm/hugetlb: check gigantic_page_runtime_supported() in return_unused_surplus_pages() Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 2/8] mm/hugetlb: make pud_huge() and follow_huge_pud() aware of non-present pud entry Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 3/8] mm, hwpoison, hugetlb: support saving mechanism of raw error pages Naoya Horiguchi
2022-07-13 4:51 ` Miaohe Lin
2022-07-13 11:54 ` HORIGUCHI NAOYA(堀口 直也) [this message]
2022-07-12 3:28 ` [mm-unstable PATCH v6 4/8] mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage Naoya Horiguchi
2022-07-13 4:24 ` Miaohe Lin
2022-07-13 11:54 ` HORIGUCHI NAOYA(堀口 直也)
2022-07-12 3:28 ` [mm-unstable PATCH v6 5/8] mm, hwpoison: set PG_hwpoison for busy hugetlb pages Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 6/8] mm, hwpoison: make __page_handle_poison returns int Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 7/8] mm, hwpoison: skip raw hwpoison page in freeing 1GB hugepage Naoya Horiguchi
2022-07-12 3:28 ` [mm-unstable PATCH v6 8/8] mm, hwpoison: enable memory error handling on " Naoya Horiguchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220713115447.GB2824071@hori.linux.bs1.fc.nec.co.jp \
--to=naoya.horiguchi@nec.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=mike.kravetz@oracle.com \
--cc=naoya.horiguchi@linux.dev \
--cc=osalvador@suse.de \
--cc=shy828301@gmail.com \
--cc=songmuchun@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox