mm: hwpoison: fix thp split handing in soft_offline_in_use_page()
Subsystems (2)
PATCH 1/1 mm: hwpoison: fix thp split handing in soft_offline_in_use_page()
From: zhongjiang <[email protected]>
When soft_offline_in_use_page() runs on a thp tail page after pmd is plit, 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().
--- mm/memory-failure.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
mm/memory-failure.c +6 -8
@@ -1823,19 +1823,17 @@ static int soft_offline_in_use_page(struct page *page, int flags)struct page *hpage =compound_head (page);if (!PageHuge (page) &&PageTransHuge (hpage)) { -lock_page (hpage); -if (!PageAnon (hpage) ||unlikely (split_huge_page (hpage))) { -unlock_page (hpage); -if (!PageAnon (hpage)) +lock_page (page); +if (!PageAnon (page) ||unlikely (split_huge_page (page))) { +unlock_page (page); +if (!PageAnon (page))pr_info ("soft offline: %#lx: non anonymous thp\n" ,page_to_pfn (page));else pr_info ("soft offline: %#lx: thp split failed\n" ,page_to_pfn (page)); -put_hwpoison_page (hpage); +put_hwpoison_page (page);return -EBUSY ; } -unlock_page (hpage); -get_hwpoison_page (page); -put_hwpoison_page (hpage); +unlock_page (page); }/*
Signature · 1 line
1.7.12.4
[Cc Kirril for the THP side]
Quoted 59 lines · zhong jiang
From: zhongjiang <[email protected]>
When
soft_offline_in_use_page()runs on a thp tail page after pmd is plit, we trigger the followingVM_BUG_ON_PAGE():Memory failure:
0x3755ff: non anonymous thp__get_any_page:0x3755ff: unknown zero refcount page type2fffff80000000Soft offlining pfn0x34d805at process virtual address0x20fff000page: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 tosplit_huge_page().Cc <[email protected]> [4.5+]Signed-off-by zhongjiang <[email protected]>--- mm/memory-failure.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)mm/memory-failure.c +6
-8@@ -1823,19 +1823,17 @@ static int soft_offline_in_use_page(struct page *page, int flags)struct page *hpage =compound_head (page);if (!PageHuge (page) &&PageTransHuge (hpage)) { -lock_page (hpage); -if (!PageAnon (hpage) ||unlikely (split_huge_page (hpage))) { -unlock_page (hpage); -if (!PageAnon (hpage)) +lock_page (page); +if (!PageAnon (page) ||unlikely (split_huge_page (page))) { +unlock_page (page); +if (!PageAnon (page))pr_info ("soft offline: %#lx: non anonymous thp\n" ,page_to_pfn (page));else pr_info ("soft offline: %#lx: thp split failed\n" ,page_to_pfn (page)); -put_hwpoison_page (hpage); +put_hwpoison_page (page);return -EBUSY ; } -unlock_page (hpage); -get_hwpoison_page (page); -put_hwpoison_page (hpage); +unlock_page (page); }/* Signature · 1 line
1.7.12.4
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 3 lines · zhong jiang
From: zhongjiang <[email protected]>
When
soft_offline_in_use_page()runs on a thp tail page after pmd is plit,
s/plit/split/
Quoted 13 lines
we trigger the following
VM_BUG_ON_PAGE():Memory failure:
0x3755ff: non anonymous thp__get_any_page:0x3755ff: unknown zero refcount page type2fffff80000000Soft offlining pfn0x34d805at process virtual address0x20fff000page: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!
Quoted 3 lines
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 tosplit_huge_page().
I don't see a description of what is going wrong and why change will fixed it. From the description, it appears as it's cosmetic-only change.
Please elaborate.
Signature · 1 line
Kirill A. Shutemov
Quoted 19 lines · Kirill A. Shutemov
Quoted 3 lines · zhong jiang
From: zhongjiang <[email protected]>
When
soft_offline_in_use_page()runs on a thp tail page after pmd is plit,s/plit/split/
Quoted 13 lines
we trigger the following
VM_BUG_ON_PAGE():Memory failure:
0x3755ff: non anonymous thp__get_any_page:0x3755ff: unknown zero refcount page type2fffff80000000Soft offlining pfn0x34d805at process virtual address0x20fff000page: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!
Quoted 7 lines
Quoted 3 lines
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 tosplit_huge_page().I don't see a description of what is going wrong and why change will fixed it. From the description, it appears as it's cosmetic-only change.
Please elaborate.
When soft_offline_in_use_page runs on a thp tail page after pmd is split, and we pass the head page to split_huge_page, Unfortunately, the tail page can be free or count turn into zero.
Thanks,
zhong jiang
Naoya Horiguchi
Acked-byQuoted 23 lines · zhong jiang
Quoted 22 lines · Kirill A. Shutemov
Quoted 3 lines · zhong jiang
From: zhongjiang <[email protected]>
When
soft_offline_in_use_page()runs on a thp tail page after pmd is plit,s/plit/split/
Quoted 16 lines
we trigger the following
VM_BUG_ON_PAGE():Memory failure:
0x3755ff: non anonymous thp__get_any_page:0x3755ff: unknown zero refcount page type2fffff80000000Soft offlining pfn0x34d805at process virtual address0x20fff000page: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 tosplit_huge_page().
Quoted 7 lines
Quoted 4 lines
I don't see a description of what is going wrong and why change will fixed it. From the description, it appears as it's cosmetic-only change.
Please elaborate.
When
soft_offline_in_use_pageruns on a thp tail page after pmd is split, and we pass the head page tosplit_huge_page, Unfortunately, the tail page can be free or count turn into zero.
I guess that you have the similar fix on memory_failure() in your mind:
commit c3901e722b2975666f42748340df798114742d6d
Author: Naoya Horiguchi <[email protected]>
Date: Thu Nov 10 10:46:23 2016 -0800
mm: hwpoison: fix thp split handling in memory_failure()
So it seems that I somehow missed fixing soft offline when I wrote commit c3901e722b29, and now you find and fix that. Thank you very much. If you resend the patch with fixing typo, can you add some reference to c3901e722b29 in the patch description to show the linkage? And you can add the following tags:
Thanks,
Naoya Horiguchi
Quoted 37 lines · Naoya Horiguchi
Quoted 23 lines · zhong jiang
Quoted 22 lines · Kirill A. Shutemov
Quoted 3 lines · zhong jiang
From: zhongjiang <[email protected]>
When
soft_offline_in_use_page()runs on a thp tail page after pmd is plit,s/plit/split/
Quoted 16 lines
we trigger the following
VM_BUG_ON_PAGE():Memory failure:
0x3755ff: non anonymous thp__get_any_page:0x3755ff: unknown zero refcount page type2fffff80000000Soft offlining pfn0x34d805at process virtual address0x20fff000page: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 tosplit_huge_page().Quoted 7 lines
Quoted 4 lines
I don't see a description of what is going wrong and why change will fixed it. From the description, it appears as it's cosmetic-only change.
Please elaborate.
When
soft_offline_in_use_pageruns on a thp tail page after pmd is split, and we pass the head page tosplit_huge_page, Unfortunately, the tail page can be free or count turn into zero.I guess that you have the similar fix on
memory_failure()in your mind:commit
c3901e722b2975666f42748340df798114742d6d
Author: Naoya Horiguchi <[email protected]>
Date: Thu Nov 10 10:46:23 2016 -0800
Quoted 7 lines
mm: hwpoison: fix thp split handling in
memory_failure()So it seems that I somehow missed fixing soft offline when I wrote commit
c3901e722b29, and now you find and fix that. Thank you very much. If you resend the patch with fixing typo, can you add some reference toc3901e722b29in the patch description to show the linkage? And you can add the following tags:
Yep, I find that that is a similar issue. hence I refer to that description in the patch you had mentioned.
I will add the above desprition you had mentioned in V2.
Thanks,
zhong jiang
Quoted 8 lines
Fixes 61f5d698cc97 ("mm: re-enable THP")Acked-by Naoya Horiguchi <[email protected]>Thanks,
Naoya Horiguchi.