MCE: fix an error of mce_bad_pages statistics
Subsystems (2)
PATCH 1/1 MCE: fix an error of mce_bad_pages statistics
On x86 platform, if we use "/sys/devices/system/memory/soft_offline_page" to offline a free page twice, the value of mce_bad_pages will be added twice. So this is an error, since the page was already marked HWPoison, we should skip the page and don't add the value of mce_bad_pages.
$ cat /proc/meminfo | grep HardwareCorrupted
soft_offline_page()
get_any_page() atomic_long_add(1, &mce_bad_pages)
The free page which marked HWPoison is still managed by page buddy allocator. So when offlining it again, get_any_page() always returns 0 with
"pr_info("%s: %#lx free buddy page\n", __func__, pfn);".
When page is allocated, the PageBuddy is removed in bad_page(), then get_any_page() returns -EIO with pr_info("%s: %#lx: unknown zero refcount page type %lx\n", so mce_bad_pages will not be added.
Signed-off-by: Jiang Liu <[email protected]>
--- mm/memory-failure.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
mm/memory-failure.c +5 -0
@@ -1375,6 +1375,11 @@ static int get_any_page(struct page *p, unsigned long pfn, int flags)if (flags &MF_COUNT_INCREASED )return 1 ; +if (PageHWPoison (p)) { +pr_info ("%s: %#lx page already poisoned\n" , __func__, pfn); +return -EBUSY ; + } +/* * The lock_memory_hotplug prevents a race with memory hotplug. * This is a big hammer, a better would be nicer.
Signature · 1 line
1.7.6.1
Quoted 30 lines · Xishi Qiu
On x86 platform, if we use "
/sys/devices/system/memory/soft_offline_page" to offline a free page twice, the value ofmce_bad_pageswill be added twice. So this is an error, since the page was already marked HWPoison, we should skip the page and don't add the value ofmce_bad_pages.$ cat /proc/meminfo | grep HardwareCorrupted
soft_offline_page()get_any_page() atomic_long_add(1, &mce_bad_pages)The free page which marked HWPoison is still managed by page buddy allocator. So when offlining it again,
get_any_page()always returns 0 with
"pr_info("%s: %#lx free buddy page\n", __func__, pfn);".When page is allocated, the PageBuddy is removed in
bad_page(), thenget_any_page()returns-EIOwith pr_info("%s: %#lx: unknown zero refcount page type %lx\n", somce_bad_pageswill not be added.Signed-off-by Xishi Qiu <[email protected]>i>>?Signed-off-by: Jiang Liu <[email protected]>
--- mm/memory-failure.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)mm/memory-failure.c +0
-0
mm/memory-failure.c static int get_any_page(struct page *p, unsigned long pfn, int flags) · line 1381
Quoted 7 lines
mm/memory-failure.c +4
-0@@ -1375,6 +1375,11 @@ static int get_any_page(struct page *p, unsigned long pfn, int flags)if (flags &MF_COUNT_INCREASED )return 1 ; +if (PageHWPoison (p)) { +pr_info ("%s: %#lx page already poisoned\n" , __func__, pfn); +return -EBUSY ; + }
Shouldn't this be done in soft_offline_page() instead, like it is done in soft_offline_huge_page() for hugepages?
Thanks.
Signature · 8 lines
Regards/Gruss,
Boris.
--
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>Quoted 42 lines · Borislav Petkov
Quoted 30 lines · Xishi Qiu
On x86 platform, if we use "
/sys/devices/system/memory/soft_offline_page" to offline a free page twice, the value ofmce_bad_pageswill be added twice. So this is an error, since the page was already marked HWPoison, we should skip the page and don't add the value ofmce_bad_pages.$ cat /proc/meminfo | grep HardwareCorrupted
soft_offline_page()get_any_page() atomic_long_add(1, &mce_bad_pages)The free page which marked HWPoison is still managed by page buddy allocator. So when offlining it again,
get_any_page()always returns 0 with
"pr_info("%s: %#lx free buddy page\n", __func__, pfn);".When page is allocated, the PageBuddy is removed in
bad_page(), thenget_any_page()returns-EIOwith pr_info("%s: %#lx: unknown zero refcount page type %lx\n", somce_bad_pageswill not be added.Signed-off-by Xishi Qiu <[email protected]>i>>?Signed-off-by: Jiang Liu <[email protected]>
--- mm/memory-failure.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)mm/memory-failure.c +0
-0mm/memory-failure.c static int get_any_page(struct page *p, unsigned long pfn, int flags) · line 1381
Quoted 7 lines
mm/memory-failure.c +4
-0@@ -1375,6 +1375,11 @@ static int get_any_page(struct page *p, unsigned long pfn, int flags)if (flags &MF_COUNT_INCREASED )return 1 ; +if (PageHWPoison (p)) { +pr_info ("%s: %#lx page already poisoned\n" , __func__, pfn); +return -EBUSY ; + }Shouldn't this be done in
soft_offline_page()instead, like it is done insoft_offline_huge_page()for hugepages?
Quoted 2 lines
Thanks.
Hi Borislav, you mean we should move this to the beginning of soft_offline_page()?
soft_offline_page()
{
...
get_any_page()
...
/*
* Synchronized using the page lock with memory_failure()
*/
if (PageHWPoison(page)) {
unlock_page(page);
put_page(page);
pr_info("soft offline: %#lx page already poisoned\n", pfn);
return -EBUSY;
}
...
}Thanks
Xishi Qiu
--
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>
Quoted 12 lines · Xishi Qiu
Hi Borislav, you mean we should move this to the beginning of
soft_offline_page()?
soft_offline_page(){ ... get_any_page() ... /* * Synchronized using the page lock with memory_failure() */ if (PageHWPoison(page)) { unlock_page(page);
Basically yes, except without the unlock_page. Where do you do lock_page earlier so that you need to unlock it now?
Thanks.
Signature · 8 lines
Regards/Gruss,
Boris.
--
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>