Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Naoya Horiguchi and committed by
Andi Kleen
43131e14 fd6a03ed

+11 -6
+2
mm/hugetlb.c
··· 615 615 return dtor == free_huge_page; 616 616 } 617 617 618 + EXPORT_SYMBOL_GPL(PageHuge); 619 + 618 620 static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid) 619 621 { 620 622 struct page *page;
+9 -6
mm/hwpoison-inject.c
··· 5 5 #include <linux/mm.h> 6 6 #include <linux/swap.h> 7 7 #include <linux/pagemap.h> 8 + #include <linux/hugetlb.h> 8 9 #include "internal.h" 9 10 10 11 static struct dentry *hwpoison_dir; ··· 14 13 { 15 14 unsigned long pfn = val; 16 15 struct page *p; 16 + struct page *hpage; 17 17 int err; 18 18 19 19 if (!capable(CAP_SYS_ADMIN)) ··· 26 24 return -ENXIO; 27 25 28 26 p = pfn_to_page(pfn); 27 + hpage = compound_head(p); 29 28 /* 30 29 * This implies unable to support free buddy pages. 31 30 */ 32 - if (!get_page_unless_zero(p)) 31 + if (!get_page_unless_zero(hpage)) 33 32 return 0; 34 33 35 - if (!PageLRU(p)) 34 + if (!PageLRU(p) && !PageHuge(p)) 36 35 shake_page(p, 0); 37 36 /* 38 37 * This implies unable to support non-LRU pages. 39 38 */ 40 - if (!PageLRU(p)) 39 + if (!PageLRU(p) && !PageHuge(p)) 41 40 return 0; 42 41 43 42 /* ··· 47 44 * We temporarily take page lock for try_get_mem_cgroup_from_page(). 48 45 * __memory_failure() will redo the check reliably inside page lock. 49 46 */ 50 - lock_page(p); 51 - err = hwpoison_filter(p); 52 - unlock_page(p); 47 + lock_page(hpage); 48 + err = hwpoison_filter(hpage); 49 + unlock_page(hpage); 53 50 if (err) 54 51 return 0; 55 52