The patch titled Subject: mm, hwpoison: enable error handling on shmem thp has been added to the -mm tree. Its filename is mm-hwpoison-enable-error-handling-on-shmem-thp.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-hwpoison-enable-error-handling-on-shmem-thp.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-hwpoison-enable-error-handling-on-shmem-thp.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Naoya Horiguchi <naoya.horiguchi@xxxxxxx> Subject: mm, hwpoison: enable error handling on shmem thp Currently hwpoison code checks PageAnon() for thp and refuses to handle errors on non-anonymous thps (just for historical reason). We now support non-anonymou thp like shmem one, so this patch suggests to enable to handle shmem thps. Fortunately, we already have can_split_huge_page() to check if a give thp is splittable, so this patch relies on it. Link: https://lkml.kernel.org/r/20210209062128.453814-1-nao.horiguchi@xxxxxxxxx Signed-off-by: Naoya Horiguchi <naoya.horiguchi@xxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Tony Luck <tony.luck@xxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory-failure.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) --- a/mm/memory-failure.c~mm-hwpoison-enable-error-handling-on-shmem-thp +++ a/mm/memory-failure.c @@ -959,20 +959,6 @@ static int __get_hwpoison_page(struct pa { struct page *head = compound_head(page); - if (!PageHuge(head) && PageTransHuge(head)) { - /* - * Non anonymous thp exists only in allocation/free time. We - * can't handle such a case correctly, so let's give it up. - * This should be better than triggering BUG_ON when kernel - * tries to touch the "partially handled" page. - */ - if (!PageAnon(head)) { - pr_err("Memory failure: %#lx: non anonymous thp\n", - page_to_pfn(page)); - return 0; - } - } - if (get_page_unless_zero(head)) { if (head == compound_head(page)) return 1; @@ -1200,21 +1186,19 @@ static int identify_page_state(unsigned static int try_to_split_thp_page(struct page *page, const char *msg) { - lock_page(page); - if (!PageAnon(page) || unlikely(split_huge_page(page))) { - unsigned long pfn = page_to_pfn(page); + struct page *head; + lock_page(page); + head = compound_head(page); + if (PageTransHuge(head) && can_split_huge_page(head, NULL) && + !split_huge_page(page)) { unlock_page(page); - if (!PageAnon(page)) - pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); - else - pr_info("%s: %#lx: thp split failed\n", msg, pfn); - put_page(page); - return -EBUSY; + return 0; } + pr_info("%s: %#lx: thp split failed\n", msg, page_to_pfn(page)); unlock_page(page); - - return 0; + put_page(page); + return -EBUSY; } static int memory_failure_hugetlb(unsigned long pfn, int flags) _ Patches currently in -mm which might be from naoya.horiguchi@xxxxxxx are mm-hwpoison-do-not-lock-page-again-when-me_huge_page-successfully-recovers.patch mm-hwpoison-enable-error-handling-on-shmem-thp.patch