diff options
author | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> | 2010-05-27 20:29:22 -0400 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2010-08-11 03:23:11 -0400 |
commit | 43131e141abdb44c487cf79af3ef1fe5164dcef9 (patch) | |
tree | 374312457143abd52f1c4b0dbada363f5a69ba55 /mm | |
parent | fd6a03edd271cf2d69a61aa8df98dd05fa6b9afd (diff) |
HWPOISON, hugetlb: support hwpoison injection for hugepage
This patch enables hwpoison injection through debug/hwpoison interfaces,
with which we can test memory error handling for free or reserved
hugepages (which cannot be tested by madvise() injector).
[AK: Export PageHuge too for the injection module]
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hugetlb.c | 2 | ||||
-rw-r--r-- | mm/hwpoison-inject.c | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 4c2efc0f3919..3c275ffd32a7 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -615,6 +615,8 @@ int PageHuge(struct page *page) | |||
615 | return dtor == free_huge_page; | 615 | return dtor == free_huge_page; |
616 | } | 616 | } |
617 | 617 | ||
618 | EXPORT_SYMBOL_GPL(PageHuge); | ||
619 | |||
618 | static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) | 620 | static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) |
619 | { | 621 | { |
620 | struct page *page; | 622 | struct page *page; |
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index 10ea71905c1f..0948f1072d6b 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/mm.h> | 5 | #include <linux/mm.h> |
6 | #include <linux/swap.h> | 6 | #include <linux/swap.h> |
7 | #include <linux/pagemap.h> | 7 | #include <linux/pagemap.h> |
8 | #include <linux/hugetlb.h> | ||
8 | #include "internal.h" | 9 | #include "internal.h" |
9 | 10 | ||
10 | static struct dentry *hwpoison_dir; | 11 | static struct dentry *hwpoison_dir; |
@@ -13,6 +14,7 @@ static int hwpoison_inject(void *data, u64 val) | |||
13 | { | 14 | { |
14 | unsigned long pfn = val; | 15 | unsigned long pfn = val; |
15 | struct page *p; | 16 | struct page *p; |
17 | struct page *hpage; | ||
16 | int err; | 18 | int err; |
17 | 19 | ||
18 | if (!capable(CAP_SYS_ADMIN)) | 20 | if (!capable(CAP_SYS_ADMIN)) |
@@ -24,18 +26,19 @@ static int hwpoison_inject(void *data, u64 val) | |||
24 | return -ENXIO; | 26 | return -ENXIO; |
25 | 27 | ||
26 | p = pfn_to_page(pfn); | 28 | p = pfn_to_page(pfn); |
29 | hpage = compound_head(p); | ||
27 | /* | 30 | /* |
28 | * This implies unable to support free buddy pages. | 31 | * This implies unable to support free buddy pages. |
29 | */ | 32 | */ |
30 | if (!get_page_unless_zero(p)) | 33 | if (!get_page_unless_zero(hpage)) |
31 | return 0; | 34 | return 0; |
32 | 35 | ||
33 | if (!PageLRU(p)) | 36 | if (!PageLRU(p) && !PageHuge(p)) |
34 | shake_page(p, 0); | 37 | shake_page(p, 0); |
35 | /* | 38 | /* |
36 | * This implies unable to support non-LRU pages. | 39 | * This implies unable to support non-LRU pages. |
37 | */ | 40 | */ |
38 | if (!PageLRU(p)) | 41 | if (!PageLRU(p) && !PageHuge(p)) |
39 | return 0; | 42 | return 0; |
40 | 43 | ||
41 | /* | 44 | /* |
@@ -44,9 +47,9 @@ static int hwpoison_inject(void *data, u64 val) | |||
44 | * We temporarily take page lock for try_get_mem_cgroup_from_page(). | 47 | * We temporarily take page lock for try_get_mem_cgroup_from_page(). |
45 | * __memory_failure() will redo the check reliably inside page lock. | 48 | * __memory_failure() will redo the check reliably inside page lock. |
46 | */ | 49 | */ |
47 | lock_page(p); | 50 | lock_page(hpage); |
48 | err = hwpoison_filter(p); | 51 | err = hwpoison_filter(hpage); |
49 | unlock_page(p); | 52 | unlock_page(hpage); |
50 | if (err) | 53 | if (err) |
51 | return 0; | 54 | return 0; |
52 | 55 | ||