Commit e87bf4f5 authored by Naoya Horiguchi's avatar Naoya Horiguchi Committed by Greg Kroah-Hartman

mm: hwpoison: fix thp split handling in memory_failure()

commit c3901e72 upstream.

When memory_failure() runs on a thp tail page after pmd is split, we
trigger the following VM_BUG_ON_PAGE():

   page:ffffd7cd819b0040 count:0 mapcount:0 mapping:         (null) index:0x1
   flags: 0x1fffc000400000(hwpoison)
   page dumped because: VM_BUG_ON_PAGE(!page_count(p))
   ------------[ cut here ]------------
   kernel BUG at /src/linux-dev/mm/memory-failure.c:1132!

memory_failure() 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().

Fixes: 61f5d698 ("mm: re-enable THP")
Link: http://lkml.kernel.org/r/1477961577-7183-1-git-send-email-n-horiguchi@ah.jp.nec.comSigned-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67c79e16
...@@ -1112,10 +1112,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags) ...@@ -1112,10 +1112,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
} }
if (!PageHuge(p) && PageTransHuge(hpage)) { if (!PageHuge(p) && PageTransHuge(hpage)) {
lock_page(hpage); lock_page(p);
if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { if (!PageAnon(p) || unlikely(split_huge_page(p))) {
unlock_page(hpage); unlock_page(p);
if (!PageAnon(hpage)) if (!PageAnon(p))
pr_err("Memory failure: %#lx: non anonymous thp\n", pr_err("Memory failure: %#lx: non anonymous thp\n",
pfn); pfn);
else else
...@@ -1126,9 +1126,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) ...@@ -1126,9 +1126,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
put_hwpoison_page(p); put_hwpoison_page(p);
return -EBUSY; return -EBUSY;
} }
unlock_page(hpage); unlock_page(p);
get_hwpoison_page(p);
put_hwpoison_page(hpage);
VM_BUG_ON_PAGE(!page_count(p), p); VM_BUG_ON_PAGE(!page_count(p), p);
hpage = compound_head(p); hpage = compound_head(p);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment