linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] mm/hwpoison: fix traverse hugetlbfs page to avoid printk flood
@ 2013-09-02 23:36 Wanpeng Li
  2013-09-02 23:36 ` [PATCH v2 2/4] mm/hwpoison: fix miss catch transparent huge page Wanpeng Li
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wanpeng Li @ 2013-09-02 23:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andi Kleen, Fengguang Wu, Naoya Horiguchi, Tony Luck, gong.chen,
	linux-mm, linux-kernel, Wanpeng Li

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;
}

Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/madvise.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 6975bc8..539eeb9 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -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);
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-09-03  8:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-02 23:36 [PATCH v2 1/4] mm/hwpoison: fix traverse hugetlbfs page to avoid printk flood Wanpeng Li
2013-09-02 23:36 ` [PATCH v2 2/4] mm/hwpoison: fix miss catch transparent huge page Wanpeng Li
2013-09-03  0:20   ` Naoya Horiguchi
2013-09-03  3:15   ` Chen Gong
2013-09-03  4:18     ` Wanpeng Li
2013-09-03  4:18     ` Wanpeng Li
2013-09-03  7:59       ` Wanpeng Li
2013-09-03  7:59       ` Wanpeng Li
     [not found]     ` <52256342.4ad52a0a.2e24.ffff8c60SMTPIN_ADDED_BROKEN@mx.google.com>
2013-09-03  8:04       ` Chen Gong
2013-09-03  8:21         ` Wanpeng Li
2013-09-03  8:21         ` Wanpeng Li
2013-09-02 23:36 ` [PATCH v2 3/4] mm/hwpoison: fix false report 2nd try page recovery Wanpeng Li
2013-09-02 23:36 ` [PATCH v2 4/4] mm/hwpoison: fix the lack of one reference count against poisoned page Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).