lkml.org 
[lkml]   [2009]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 4/4] HWPOISON: memory cgroup based hwpoison injection filtering
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
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 <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/pagemap.h>
+#include <linux/page_cgroup.h>
+#include <linux/cgroup.h>
#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)
--



\
 
 \ /
  Last update: 2009-08-31 12:47    [W:0.087 / U:6.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site