Re: [PATCH -next v2] mm: hwpoison: support recovery from HugePage copy-on-write faults

From: HORIGUCHI NAOYA(堀口 直也)
Date: Thu Apr 13 2023 - 22:57:13 EST


On Thu, Apr 13, 2023 at 09:13:49PM +0800, Liu Shixin wrote:
> copy-on-write of hugetlb user pages with uncorrectable errors will result
> in a kernel crash. This is because the copy is performed in kernel mode
> and in general we can not handle accessing memory with such errors while
> in kernel mode. 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. However,
> the separate hugetlb copy-on-write code paths were not modified as part
> of 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_large_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.
>
> Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx>
> Acked-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>

Looks good to me.

Reviewed-by: Naoya Horiguchi <naoya.horiguchi@xxxxxxx>