Skip to contentSkip to conversation

Patch "mm: hwpoison: fix thp split handling in memory_failure()" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Nov 15, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

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

to the 4.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mm-hwpoison-fix-thp-split-handling-in-memory_failure.patch
and it can be found in the queue-4.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From c3901e722b2975666f42748340df798114742d6d Mon Sep 17 00:00:00 2001

From: Naoya Horiguchi <[email protected]>
Date: Thu, 10 Nov 2016 10:46:23 -0800
Subject: mm: hwpoison: fix thp split handling in memory_failure()

From: Naoya Horiguchi <[email protected]>

commit c3901e722b2975666f42748340df798114742d6d 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().

---
 mm/memory-failure.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
mm/memory-failure.c +5 -7
@@ -1112,10 +1112,10 @@ int memory_failure(unsigned long pfn, in
 	}
 
 	if (!PageHuge(p) && PageTransHuge(hpage)) {
-		lock_page(hpage);
-		if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
-			unlock_page(hpage);
-			if (!PageAnon(hpage))
+		lock_page(p);
+		if (!PageAnon(p) || unlikely(split_huge_page(p))) {
+			unlock_page(p);
+			if (!PageAnon(p))
 				pr_err("Memory failure: %#lx: non anonymous thp\n",
 					pfn);
 			else
@@ -1126,9 +1126,7 @@ int memory_failure(unsigned long pfn, in
 			put_hwpoison_page(p);
 			return -EBUSY;
 		}
-		unlock_page(hpage);
-		get_hwpoison_page(p);
-		put_hwpoison_page(hpage);
+		unlock_page(p);
 		VM_BUG_ON_PAGE(!page_count(p), p);
 		hpage = compound_head(p);
 	}

Patches currently in stable-queue which might be from [email protected] are

queue-4.8/mm-hwpoison-fix-thp-split-handling-in-memory_failure.patch queue-4.8/mm-hugetlb-fix-huge-page-reservation-leak-in-private-mapping-error-paths.patch