Re: [mm-unstable PATCH v6 4/8] mm, hwpoison: make unpoison aware of raw error info in hwpoisoned hugepage

From: HORIGUCHI NAOYA(堀口 直也)
Date: Wed Jul 13 2022 - 07:54:15 EST


On Wed, Jul 13, 2022 at 12:24:46PM +0800, Miaohe Lin wrote:
> On 2022/7/12 11:28, Naoya Horiguchi wrote:
> > From: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
> >
> > Raw error info list needs to be removed when hwpoisoned hugetlb is
> > unpoisoned. And unpoison handler needs to know how many errors there
> > are in the target hugepage. So add them.
> >
> > HPageVmemmapOptimized(hpage) and HPageRawHwpUnreliable(hpage)) can't be
> > unpoisoned, so let's skip them.
> >
> > Signed-off-by: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> This patch looks good to me with some nits below.
>
> > ---
> ...
> >
> > -void hugetlb_clear_page_hwpoison(struct page *hpage)
> > +static unsigned long free_raw_hwp_pages(struct page *hpage, bool move_flag)
> > {
> > struct llist_head *head;
> > struct llist_node *t, *tnode;
> > + unsigned long count = 0;
> >
> > - if (!HPageRawHwpUnreliable(hpage))
> > - ClearPageHWPoison(hpage);
> > + /*
> > + * HPageVmemmapOptimized hugepages can't be unpoisoned because
> > + * struct pages for tail pages are required to free hwpoisoned
> > + * hugepages. HPageRawHwpUnreliable hugepages shouldn't be
> > + * unpoisoned by definition.
> > + */
> > + if (HPageVmemmapOptimized(hpage) || HPageRawHwpUnreliable(hpage))
>
> If move_flag == false, i.e. in unpoison case, tail pages are not touched. So HPageVmemmapOptimized
> can be ignored in this case? Or leave it as above to keep the code simple?

Oh, right. We can make HPageVmemmapOptimized() more conditional.

>
> > + return 0;
> > 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);
> > + if (move_flag)
> > + SetPageHWPoison(p->page);
> > kfree(p);
> > + count++;
> > }
> > llist_del_all(head);
> > + return count;
> > +}
> > +
> > +void hugetlb_clear_page_hwpoison(struct page *hpage)
> > +{
> > + if (!HPageRawHwpUnreliable(hpage))
>
> It seems we can return here if HPageRawHwpUnreliable as there's nothing to do?

OK, I'll update this, too.

>
> Anyway, for what it worth,
>
> Reviewed-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>

Thank you.
- Naoya Horiguchi

>
> Thanks.
>
> > + ClearPageHWPoison(hpage);
> > + free_raw_hwp_pages(hpage, true);
> > }
> >
> > /*