path: root/mm/hwpoison-inject.c
diff options
authorAndi Kleen <>2009-12-16 12:19:59 +0100
committerAndi Kleen <>2009-12-16 12:19:59 +0100
commit4fd466eb46a6a917c317a87fb94bfc7252a0f7ed (patch)
tree003b28724241a22a41dc9ae067f30beadbf76e6a /mm/hwpoison-inject.c
parentd324236b3333e87c8825b35f2104184734020d35 (diff)
HWPOISON: add memory cgroup filter
The hwpoison test suite need to inject hwpoison to a collection of selected task pages, and must not touch pages not owned by them and thus kill important system processes such as init. (But it's OK to mis-hwpoison free/unowned pages as well as shared clean pages. Mis-hwpoison of shared dirty pages will kill all tasks, so the test suite will target all or non of such tasks in the first place.) The memory cgroup serves this purpose well. We can put the target processes under the control of a memory cgroup, and tell the hwpoison injection code to only kill pages associated with some active memory cgroup. The prerequisite for doing hwpoison stress tests with mem_cgroup is, the mem_cgroup code tracks task pages _accurately_ (unless page is locked). Which we believe is/should be true. The benefits are simplification of hwpoison injector code. Also the mem_cgroup code will automatically be tested by hwpoison test cases. The alternative interfaces pin-pfn/unpin-pfn can also delegate the (process and page flags) filtering functions reliably to user space. However prototype implementation shows that this scheme adds more complexity than we wanted. Example test case: mkdir /cgroup/hwpoison usemem -m 100 -s 1000 & echo `jobs -p` > /cgroup/hwpoison/tasks memcg_ino=$(ls -id /cgroup/hwpoison | cut -f1 -d' ') echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg page-types -p `pidof init` --hwpoison # shall do nothing page-types -p `pidof usemem` --hwpoison # poison its pages [AK: Fix documentation] [Add fix for problem noticed by Li Zefan <>; dentry in the css could be NULL] CC: KOSAKI Motohiro <> CC: Hugh Dickins <> CC: Daisuke Nishimura <> CC: Balbir Singh <> CC: KAMEZAWA Hiroyuki <> CC: Li Zefan <> CC: Paul Menage <> CC: Nick Piggin <> CC: Andi Kleen <> Signed-off-by: Wu Fengguang <> Signed-off-by: Andi Kleen <>
Diffstat (limited to 'mm/hwpoison-inject.c')
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index c4dfd89f654a..c838735ac31d 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -112,6 +112,13 @@ static int pfn_inject_init(void)
if (!dentry)
goto fail;
+ dentry = debugfs_create_u64("corrupt-filter-memcg", 0600,
+ hwpoison_dir, &hwpoison_filter_memcg);
+ if (!dentry)
+ goto fail;
return 0;