Skip to content

Commit 8d547ff

Browse files
Naoya Horiguchitorvalds
authored andcommitted
mm/memory-failure.c: move refcount only in !MF_COUNT_INCREASED
mce-test detected a test failure when injecting error to a thp tail page. This is because we take page refcount of the tail page in madvise_hwpoison() while the fix in commit a3e0f9e ("mm/memory-failure.c: transfer page count from head page to tail page after split thp") assumes that we always take refcount on the head page. When a real memory error happens we take refcount on the head page where memory_failure() is called without MF_COUNT_INCREASED set, so it seems to me that testing memory error on thp tail page using madvise makes little sense. This patch cancels moving refcount in !MF_COUNT_INCREASED for valid testing. [[email protected]: s/&&/&/] Signed-off-by: Naoya Horiguchi <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Wanpeng Li <[email protected]> Cc: Chen Gong <[email protected]> Cc: <[email protected]> [3.9+: a3e0f9e] Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent fb37bb0 commit 8d547ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mm/memory-failure.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,10 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
945945
* to it. Similarly, page lock is shifted.
946946
*/
947947
if (hpage != p) {
948-
put_page(hpage);
949-
get_page(p);
948+
if (!(flags & MF_COUNT_INCREASED)) {
949+
put_page(hpage);
950+
get_page(p);
951+
}
950952
lock_page(p);
951953
unlock_page(hpage);
952954
*hpagep = p;

0 commit comments

Comments
 (0)