Skip to contentSkip to conversation

mm: hwpoison: Use compound_head() flags for huge pages

PATCH Applied James Morse 3 participants 3 messages May 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: hwpoison: Use compound_head() flags for huge pages

memory_failure() chooses a recovery action function based on the page flags. For huge pages it uses the tail page flags which don't have anything interesting set, resulting in:

Quoted 2 lines

Memory failure: 0x9be3b4: Unknown page state
Memory failure: 0x9be3b4: recovery action for unknown page: Failed

Instead, save a copy of the head page's flags if this is a huge page, this means if there are no relevant flags for this tail page, we use the head pages flags instead. This results in the me_huge_page() recovery action being called:

Quoted 1 line

Memory failure: 0x9b7969: recovery action for huge page: Delayed

For hugepages that have not yet been allocated, this allows the hugepage to be dequeued.

---
This is intended as a fix, but I can't find the patch that introduced this behaviour. (not recent, and there is a lot of history down there!)

This doesn't apply to stable trees before v3.10...
Cc: [email protected] # 3.10.105

 mm/memory-failure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/memory-failure.c +4 -1
index 2527dfeddb00..44a6a33af219 100644
@@ -1184,7 +1184,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
 	 * page_remove_rmap() in try_to_unmap_one(). So to determine page status
 	 * correctly, we save a copy of the page flags at this time.
 	 */
-	page_flags = p->flags;
+	if (PageHuge(p))
+		page_flags = hpage->flags;
+	else
+		page_flags = p->flags;
 
 	/*
 	 * unpoison always clear PG_hwpoison inside page lock
Signature · 7 lines
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 33 lines · James Morse

memory_failure() chooses a recovery action function based on the page flags. For huge pages it uses the tail page flags which don't have anything interesting set, resulting in:

Quoted 2 lines

Memory failure: 0x9be3b4: Unknown page state
Memory failure: 0x9be3b4: recovery action for unknown page: Failed

Instead, save a copy of the head page's flags if this is a huge page, this means if there are no relevant flags for this tail page, we use the head pages flags instead. This results in the me_huge_page() recovery action being called:

Quoted 1 line

Memory failure: 0x9b7969: recovery action for huge page: Delayed

For hugepages that have not yet been allocated, this allows the hugepage to be dequeued.

---
This is intended as a fix, but I can't find the patch that introduced this behaviour. (not recent, and there is a lot of history down there!)

This doesn't apply to stable trees before v3.10...
Cc: [email protected] # 3.10.105

 mm/memory-failure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/memory-failure.c +0 -0
index 2527dfeddb00..44a6a33af219 100644
@@ -1184,7 +1184,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
 	 * page_remove_rmap() in try_to_unmap_one(). So to determine page status

mm/memory-failure.c int memory_failure(unsigned long pfn, int trapno, int flags) · line 1193

Quoted 10 lines
mm/memory-failure.c +4 -1
 	 * correctly, we save a copy of the page flags at this time.
 	 */
-	page_flags = p->flags;
+	if (PageHuge(p))
+		page_flags = hpage->flags;
+	else
+		page_flags = p->flags;
 
 	/*
 	 * unpoison always clear PG_hwpoison inside page lock

I can confirm that this patch reduces the number of failing cases when running hugepage tests from mce-tests suite.

FWIW,

Thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Acked-by on v1 1/1
#2 lore raw
In reply to James Morse
Quoted 10 lines · James Morse

memory_failure() chooses a recovery action function based on the page flags. For huge pages it uses the tail page flags which don't have anything interesting set, resulting in:

Quoted 2 lines

Memory failure: 0x9be3b4: Unknown page state
Memory failure: 0x9be3b4: recovery action for unknown page: Failed

Instead, save a copy of the head page's flags if this is a huge page, this means if there are no relevant flags for this tail page, we use the head pages flags instead. This results in the me_huge_page() recovery action being called:

Quoted 7 lines
Quoted 1 line

Memory failure: 0x9b7969: recovery action for huge page: Delayed

For hugepages that have not yet been allocated, this allows the hugepage to be dequeued.

Looks good to me.

Quoted 3 lines

---
This is intended as a fix, but I can't find the patch that introduced this behaviour. (not recent, and there is a lot of history down there!)

Please add a tag

Fixes 524fca1e7356 ("HWPOISON: fix misjudgement of page_action() for errors on mlocked pages")
Quoted 3 lines

This doesn't apply to stable trees before v3.10...
Cc: [email protected] # 3.10.105

You can skip older stable kernels to which the fix isn't cleanly applicable.

Thanks,
Naoya Horiguchi

Quoted 24 lines
 mm/memory-failure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/memory-failure.c +4 -1
index 2527dfeddb00..44a6a33af219 100644
@@ -1184,7 +1184,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
 	 * page_remove_rmap() in try_to_unmap_one(). So to determine page status
 	 * correctly, we save a copy of the page flags at this time.
 	 */
-	page_flags = p->flags;
+	if (PageHuge(p))
+		page_flags = hpage->flags;
+	else
+		page_flags = p->flags;
 
 	/*
 	 * unpoison always clear PG_hwpoison inside page lock
Signature · 1 line
2.11.0

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>