Signed-off-by: Wu Fengguang --- mm/hwpoison-inject.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) --- linux-mm.orig/mm/hwpoison-inject.c 2009-08-30 18:18:41.000000000 +0800 +++ linux-mm/mm/hwpoison-inject.c 2009-08-30 18:24:33.000000000 +0800 @@ -5,10 +5,13 @@ #include #include #include +#include +#include #include "internal.h" static struct dentry *hwpoison_dir; +static u32 hwpoison_filter_memcg; static u32 hwpoison_filter_dev_major = ~0U; static u32 hwpoison_filter_dev_minor = ~0U; static u64 hwpoison_filter_flags_mask; @@ -53,8 +56,37 @@ static int hwpoison_filter_dev(struct pa return 0; } +static int hwpoison_filter_cg(struct page *p) +{ + struct mem_cgroup *mem; + struct cgroup_subsys_state *css; + int ret; + + if (!hwpoison_filter_memcg) + return 0; + + mem = try_get_mem_cgroup_from_page(p); + if (!mem) + return -EINVAL; + + css = mem_cgroup_css(mem); + if (!css) + return -EINVAL; + + if (css_id(css) != hwpoison_filter_memcg) + ret = -EINVAL; + else + ret = 0; + + css_put(css); + return ret; +} + static int hwpoison_filter(struct page *p) { + if (hwpoison_filter_cg(p)) + return 1; + if (hwpoison_filter_dev(p)) return -EINVAL; @@ -119,6 +151,11 @@ static int pfn_inject_init(void) if (!dentry) goto fail; + dentry = debugfs_create_u32("corrupt-filter-memcg", 0600, + hwpoison_dir, &hwpoison_filter_memcg); + if (!dentry) + goto fail; + dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600, hwpoison_dir, &hwpoison_filter_dev_major); if (!dentry) -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/