mm/hwpoison: fix traverse hugetlbfs page to avoid printk flood
Subsystems (3)
PATCH RESEND v2 1/4 mm/hwpoison: fix traverse hugetlbfs page to avoid printk flood
madvise_hwpoison won't check if the page is small page or huge page and traverse in small page granularity against the range unconditional, which result in a printk flood "MCE xxx: already hardware poisoned" if the page is huge page. This patch fix it by increase compound_order(compound_head(page)) for huge page iterator.
Testcase:
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <errno.h>
#define PAGES_TO_TEST 3
#define PAGE_SIZE 4096 * 512
int main(void)
{
char *mem;
int i;
mem = mmap(NULL, PAGES_TO_TEST * PAGE_SIZE,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, 0, 0);
if (madvise(mem, PAGES_TO_TEST * PAGE_SIZE, MADV_HWPOISON) == -1)
return -1;
munmap(mem, PAGES_TO_TEST * PAGE_SIZE);
return 0;
}--- mm/madvise.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/madvise.c +3 -2
@@ -343,10 +343,11 @@ static long madvise_remove(struct vm_area_struct *vma,*/ static int madvise_hwpoison (int bhv,unsigned long start,unsigned long end) { +struct page *p;if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -for (; start < end; start +=PAGE_SIZE ) { -struct page *p; +for (; start < end; start +=PAGE_SIZE << +compound_order (compound_head (p))) {int ret; ret =get_user_pages_fast (start,1 ,0 , &p);
Signature · 7 lines
1.8.1.2 -- 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>
PATCH RESEND v2 2/4 mm/hwpoison: fix miss catch transparent huge page
Changelog:
*v1 -> v2: reverse PageTransHuge(page) && !PageHuge(page) check
PageTransHuge() can't guarantee the page is transparent huge page since it return true for both transparent huge and hugetlbfs pages. This patch fix it by check the page is also !hugetlbfs page.
Before patch:
[ 121.571128] Injecting memory failure at pfn 23a200 [ 121.571141] MCE 0x23a200: huge page recovery: Delayed [ 140.355100] MCE: Memory failure is now running on 0x23a200
After patch:
[ 94.290793] Injecting memory failure at pfn 23a000 [ 94.290800] MCE 0x23a000: huge page recovery: Delayed [ 105.722303] MCE: Software-unpoisoned page 0x23a000
--- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory-failure.c +1 -1
@@ -1349,7 +1349,7 @@ int unpoison_memory(unsigned long pfn)* worked by memory_failure() and the page lock is not held yet. * In such case, we yield to memory_failure() and make unpoison fail. */ -if (PageTransHuge (page)) { +if (!PageHuge (page) &&PageTransHuge (page)) {pr_info ("MCE: Memory failure is now running on %#lx\n" , pfn);return 0 ; }
Signature · 7 lines
1.8.1.2 -- 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>
Re: [RESEND PATCH v2 2/4] mm/hwpoison: fix miss catch transparent huge page
Quoted 2 lines
Reviewed-by Naoya Horiguchi <[email protected]>Signed-off-by Wanpeng Li <[email protected]>
-Andi
--
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>
PATCH RESEND v2 3/4 mm/hwpoison: fix false report 2nd try page recovery
In reply to Wanpeng LiIf the page is poisoned by software inject w/ MF_COUNT_INCREASED flag, there is a false report 2nd try page recovery which is not truth, this patch fix it by report first try free buddy page recovery if MF_COUNT_INCREASED is set.
Before patch:
[ 346.332041] Injecting memory failure at pfn 200010 [ 346.332189] MCE 0x200010: free buddy, 2nd try page recovery: Delayed
After patch:
[ 297.742600] Injecting memory failure at pfn 200010 [ 297.742941] MCE 0x200010: free buddy page recovery: Delayed
--- mm/memory-failure.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
mm/memory-failure.c +4 -2
@@ -1114,8 +1114,10 @@ int memory_failure(unsigned long pfn, int trapno, int flags)* shake_page could have turned it free. */ if (is_free_buddy_page (p)) { -action_result (pfn,"free buddy, 2nd try" , -DELAYED ); +if (flags &MF_COUNT_INCREASED ) +action_result (pfn,"free buddy" ,DELAYED ); +else +action_result (pfn,"free buddy, 2nd try" ,DELAYED );return 0 ; }action_result (pfn,"non LRU" ,IGNORED );
Signature · 7 lines
1.7.5.4 -- 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>
Re: [RESEND PATCH v2 3/4] mm/hwpoison: fix false report 2nd try page recovery
Quoted 2 lines
Reviewed-by Naoya Horiguchi <[email protected]>Signed-off-by Wanpeng Li <[email protected]>
-Andi
--
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>
PATCH RESEND v2 4/4 mm/hwpoison: fix the lack of one reference count against poisoned page
In reply to Wanpeng LiThe lack of one reference count against poisoned page for hwpoison_inject w/o hwpoison_filter enabled result in hwpoison detect -1 users still referenced the page, however, the number should be 0 except the poison handler held one after successfully unmap. This patch fix it by hold one referenced count against poisoned page for hwpoison_inject w/ and w/o hwpoison_filter enabled.
Before patch:
[ 71.902112] Injecting memory failure at pfn 224706 [ 71.902137] MCE 0x224706: dirty LRU page recovery: Failed [ 71.902138] MCE 0x224706: dirty LRU page still referenced by -1 users
After patch:
[ 94.710860] Injecting memory failure at pfn 215b68 [ 94.710885] MCE 0x215b68: dirty LRU page recovery: Recovered
--- mm/hwpoison-inject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
mm/hwpoison-inject.c +3 -2
@@ -20,8 +20,6 @@ static int hwpoison_inject(void *data, u64 val)if (!capable (CAP_SYS_ADMIN ))return -EPERM ; -if (!hwpoison_filter_enable) - goto inject;if (!pfn_valid (pfn))return -ENXIO ;
@@ -33,6 +31,9 @@ static int hwpoison_inject(void *data, u64 val)if (!get_page_unless_zero (hpage))return 0 ; +if (!hwpoison_filter_enable) + goto inject; +if (!PageLRU (p) && !PageHuge (p))shake_page (p,0 );/*
Signature · 7 lines
1.8.1.2 -- 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>
Re: [RESEND PATCH v2 4/4] mm/hwpoison: fix the lack of one reference count against poisoned page
Quoted 2 lines
Reviewed-by Naoya Horiguchi <[email protected]>Signed-off-by Wanpeng Li <[email protected]>
-Andi
--
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 2 lines
Reviewed-by Naoya Horiguchi <[email protected]>Signed-off-by Wanpeng Li <[email protected]>
--
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>
This is good - but the real solution is to stop poisoning entire huge pages ... they should be broken into 4K pages and just one 4K page should be poisoned.
Naoya Horiguchi: I thought that you were looking at this problem some months ago. Any progress?
-Tony
--
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 4 lines · Tony
This is good - but the real solution is to stop poisoning entire huge pages ... they should be broken into 4K pages and just one 4K page should be poisoned.
Naoya Horiguchi: I thought that you were looking at this problem some months ago. Any progress?
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Thanks,
Naoya Horiguchi
--
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 10 lines · Naoya Horiguchi
Quoted 4 lines · Tony
This is good - but the real solution is to stop poisoning entire huge pages ... they should be broken into 4K pages and just one 4K page should be poisoned.
Naoya Horiguchi: I thought that you were looking at this problem some months ago. Any progress?
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Agreed. ;-)
Regards,
Wanpeng Li
Quoted 9 lines
Thanks,
Naoya Horiguchi--
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>
--
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 6 lines
Quoted 4 lines
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Agreed. ;-)
Agreed that huge pages should be split - or that it is not worth splitting them?
Actually I wonder how useful huge pages still are - transparent huge pages may give most of the benefits without having to modify applications to use them. Plus the kernel does know how to split them when an error occurs (which I care about more than most people).
-Tony
--
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>
Hi Tony,
Quoted 9 lines · Tony
Quoted 6 lines
Quoted 4 lines
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Agreed. ;-)
Agreed that huge pages should be split - or that it is not worth splitting them?
Split hugepages will introduce more complexity and there is no other potential users currently as mentioned by Naoya. This patch should be applied as a work around before hugetlbfs support splitting.
Quoted 4 lines
Actually I wonder how useful huge pages still are - transparent huge pages may give most of the benefits without having to modify applications to use them. Plus the kernel does know how to split them when an error occurs (which I care about more than most people).
Transparent huge pages are not helpful for DB workload which there is a lot of shared memory, however, transparent huge pages just doing process local memory allocation.
Regards,
Wanpeng Li
Quoted 2 lines
-Tony
--
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 2 lines
Transparent huge pages are not helpful for DB workload which there is a lot of shared memory
Hmm. Perhaps they should be. If a database allocates most[1] of the memory on a machine to a shared memory segment - that *ought* to be a candidate for using transparent huge pages. Now that we have them they seem a better choice (much more flexibility) than hugetlbfs.
-Tony
[1] I've been told that it is normal to configure over 95% of physical memory to the shared memory region to run a particular transaction based benchmark with one commercial data base application.
--
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>
Hi Tony,
Quoted 9 lines · Tony
Quoted 6 lines
Quoted 4 lines
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Agreed. ;-)
Agreed that huge pages should be split - or that it is not worth splitting them?
Split hugepages will introduce more complexity and there is no other potential users currently as mentioned by Naoya. This patch should be applied as a work around before hugetlbfs support splitting.
Quoted 4 lines
Actually I wonder how useful huge pages still are - transparent huge pages may give most of the benefits without having to modify applications to use them. Plus the kernel does know how to split them when an error occurs (which I care about more than most people).
Transparent huge pages are not helpful for DB workload which there is a lot of shared memory, however, transparent huge pages just doing process local memory allocation.
Regards,
Wanpeng Li
Quoted 2 lines
-Tony
--
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 10 lines · Naoya Horiguchi
Quoted 4 lines · Tony
This is good - but the real solution is to stop poisoning entire huge pages ... they should be broken into 4K pages and just one 4K page should be poisoned.
Naoya Horiguchi: I thought that you were looking at this problem some months ago. Any progress?
Sorry, I have no meaningful progress on this. Splitting hugepages is not a trivial operation, and introduce more complexity on hugetlbfs code. I don't hit on any usecase of it rather than memory failure, so I'm not sure that it's worth doing now.
Agreed. ;-)
Regards,
Wanpeng Li
Quoted 9 lines
Thanks,
Naoya Horiguchi--
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>
--
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>