[PATCH 7/9] HWPOISON, hugetlb: fix unpoison for hugepage

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Naoya Horiguchi
Date: Tuesday, August 10, 2010 - 2:27 am

Currently unpoisoning hugepages doesn't work because it's not enough
to just clear PG_HWPoison bits and we need to link the hugepage
to be unpoisoned back to the free hugepage list.
To do this, we get and put hwpoisoned hugepage whose refcount is 0.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
---
 mm/memory-failure.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git linux-mce-hwpoison/mm/memory-failure.c linux-mce-hwpoison/mm/memory-failure.c
index 0bfe5b3..1f54901 100644
--- linux-mce-hwpoison/mm/memory-failure.c
+++ linux-mce-hwpoison/mm/memory-failure.c
@@ -1153,9 +1153,19 @@ int unpoison_memory(unsigned long pfn)
 	nr_pages = 1 << compound_order(page);
 
 	if (!get_page_unless_zero(page)) {
-		if (TestClearPageHWPoison(p))
+		/* The page to be unpoisoned was free one when hwpoisoned */
+		if (TestClearPageHWPoison(page))
 			atomic_long_sub(nr_pages, &mce_bad_pages);
 		pr_debug("MCE: Software-unpoisoned free page %#lx\n", pfn);
+		if (PageHuge(page)) {
+			/*
+			 * To unpoison free hugepage, we get and put it
+			 * to move it back to the free list.
+			 */
+			get_page(page);
+			clear_page_hwpoison_huge_page(page);
+			put_page(page);
+		}
 		return 0;
 	}
 
@@ -1170,9 +1180,9 @@ int unpoison_memory(unsigned long pfn)
 		pr_debug("MCE: Software-unpoisoned page %#lx\n", pfn);
 		atomic_long_sub(nr_pages, &mce_bad_pages);
 		freeit = 1;
+		if (PageHuge(page))
+			clear_page_hwpoison_huge_page(page);
 	}
-	if (PageHuge(p))
-		clear_page_hwpoison_huge_page(page);
 	unlock_page(page);
 
 	put_page(page);
-- 
1.7.2.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 1/9] HWPOISON, hugetlb: move PG_HWPoison bit check, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 3/9] hugetlb: rename hugepage allocation functions, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 4/9] hugetlb: redefine hugepage copy functions, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 6/9] HWPOISON, hugetlb: soft offlining for hugepage, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 7/9] HWPOISON, hugetlb: fix unpoison for hugepage, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 8/9] page-types.c: fix name of unpoison interface, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
[PATCH 9/9] hugetlb: add corrupted hugepage counter, Naoya Horiguchi, (Tue Aug 10, 2:27 am)
Re: [PATCH 0/9] Hugepage migration (v2), Christoph Lameter, (Wed Aug 11, 6:09 am)
Re: [PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Thu Aug 12, 12:53 am)
[RFC] [PATCH 2/4] dio: add page locking for direct I/O, Naoya Horiguchi, (Thu Aug 12, 12:59 am)
Re: [PATCH 0/9] Hugepage migration (v2), Christoph Lameter, (Fri Aug 13, 5:47 am)
Re: [RFC] [PATCH 2/4] dio: add page locking for direct I/O, Naoya Horiguchi, (Sun Aug 15, 7:07 pm)
Re: [PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Mon Aug 16, 2:19 am)
Re: [PATCH 0/9] Hugepage migration (v2), Christoph Lameter, (Mon Aug 16, 5:19 am)
Re: [PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Mon Aug 16, 7:37 pm)
Re: [RFC] [PATCH 2/4] dio: add page locking for direct I/O, Naoya Horiguchi, (Tue Aug 17, 1:17 am)
Re: [PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Tue Aug 17, 1:18 am)
Re: [PATCH 0/9] Hugepage migration (v2), Andi Kleen, (Tue Aug 17, 2:40 am)
Re: [RFC] [PATCH 2/4] dio: add page locking for direct I/O, Christoph Lameter, (Tue Aug 17, 9:41 am)
Re: [PATCH 0/9] Hugepage migration (v2), Naoya Horiguchi, (Wed Aug 18, 12:32 am)
Re: [PATCH 0/9] Hugepage migration (v2), Andi Kleen, (Wed Aug 18, 12:46 am)
Re: [PATCH 9/9] hugetlb: add corrupted hugepage counter, Wu Fengguang, (Wed Aug 18, 6:57 pm)
Re: [PATCH 1/9] HWPOISON, hugetlb: move PG_HWPoison bit check, Naoya Horiguchi, (Thu Aug 19, 12:55 am)
Re: [PATCH 9/9] hugetlb: add corrupted hugepage counter, Naoya Horiguchi, (Mon Aug 23, 8:01 pm)
Re: [PATCH 9/9] hugetlb: add corrupted hugepage counter, Wu Fengguang, (Mon Aug 23, 8:08 pm)