Skip to content

Commit 84fe804

Browse files
xiongzhongjianggregkh
authored andcommitted
mm: hwpoison: fix thp split handing in soft_offline_in_use_page()
commit 46612b7 upstream. When soft_offline_in_use_page() runs on a thp tail page after pmd is split, we trigger the following VM_BUG_ON_PAGE(): Memory failure: 0x3755ff: non anonymous thp __get_any_page: 0x3755ff: unknown zero refcount page type 2fffff80000000 Soft offlining pfn 0x34d805 at process virtual address 0x20fff000 page:ffffea000d360140 count:0 mapcount:0 mapping:0000000000000000 index:0x1 flags: 0x2fffff80000000() raw: 002fffff80000000 ffffea000d360108 ffffea000d360188 0000000000000000 raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: VM_BUG_ON_PAGE(page_ref_count(page) == 0) ------------[ cut here ]------------ kernel BUG at ./include/linux/mm.h:519! soft_offline_in_use_page() passed refcount and page lock from tail page to head page, which is not needed because we can pass any subpage to split_huge_page(). Naoya had fixed a similar issue in c3901e7 ("mm: hwpoison: fix thp split handling in memory_failure()"). But he missed fixing soft offline. Link: http://lkml.kernel.org/r/[email protected] Fixes: 61f5d69 ("mm: re-enable THP") Signed-off-by: zhongjiang <[email protected]> Acked-by: Naoya Horiguchi <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: <[email protected]> [4.5+] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7a34997 commit 84fe804

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

mm/memory-failure.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,19 +1825,17 @@ static int soft_offline_in_use_page(struct page *page, int flags)
18251825
struct page *hpage = compound_head(page);
18261826

18271827
if (!PageHuge(page) && PageTransHuge(hpage)) {
1828-
lock_page(hpage);
1829-
if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
1830-
unlock_page(hpage);
1831-
if (!PageAnon(hpage))
1828+
lock_page(page);
1829+
if (!PageAnon(page) || unlikely(split_huge_page(page))) {
1830+
unlock_page(page);
1831+
if (!PageAnon(page))
18321832
pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page));
18331833
else
18341834
pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page));
1835-
put_hwpoison_page(hpage);
1835+
put_hwpoison_page(page);
18361836
return -EBUSY;
18371837
}
1838-
unlock_page(hpage);
1839-
get_hwpoison_page(page);
1840-
put_hwpoison_page(hpage);
1838+
unlock_page(page);
18411839
}
18421840

18431841
/*

0 commit comments

Comments
 (0)