diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-09-09 18:35:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 16:29:01 -0400 |
commit | 94a59fb36ee91b3f977a9b914ec701efe40041de (patch) | |
tree | c1f676a2a8195a4f2cde5b863ba78db19f2fc6dd /mm | |
parent | 2fc045247089ad4ed611ec20cc3a736c0212bf1a (diff) |
hwpoison: use page_cgroup_ino for filtering by memcg
Hwpoison allows to filter pages by memory cgroup ino. Currently, it
calls try_get_mem_cgroup_from_page to obtain the cgroup from a page and
then its ino using cgroup_ino, but now we have a helper method for
that, page_cgroup_ino, so use it instead.
This patch also loosens the hwpoison memcg filter dependency rules - it
makes it depend on CONFIG_MEMCG instead of CONFIG_MEMCG_SWAP, because
hwpoison memcg filter does not require anything (nor it used to) from
CONFIG_MEMCG_SWAP side.
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Reviewed-by: Andres Lagar-Cavilla <andreslc@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hwpoison-inject.c | 5 | ||||
-rw-r--r-- | mm/memory-failure.c | 16 |
2 files changed, 3 insertions, 18 deletions
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index aeba0edd6e44..9d26fd9fefe4 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c | |||
@@ -45,12 +45,9 @@ static int hwpoison_inject(void *data, u64 val) | |||
45 | /* | 45 | /* |
46 | * do a racy check with elevated page count, to make sure PG_hwpoison | 46 | * do a racy check with elevated page count, to make sure PG_hwpoison |
47 | * will only be set for the targeted owner (or on a free page). | 47 | * will only be set for the targeted owner (or on a free page). |
48 | * We temporarily take page lock for try_get_mem_cgroup_from_page(). | ||
49 | * memory_failure() will redo the check reliably inside page lock. | 48 | * memory_failure() will redo the check reliably inside page lock. |
50 | */ | 49 | */ |
51 | lock_page(hpage); | ||
52 | err = hwpoison_filter(hpage); | 50 | err = hwpoison_filter(hpage); |
53 | unlock_page(hpage); | ||
54 | if (err) | 51 | if (err) |
55 | goto put_out; | 52 | goto put_out; |
56 | 53 | ||
@@ -126,7 +123,7 @@ static int pfn_inject_init(void) | |||
126 | if (!dentry) | 123 | if (!dentry) |
127 | goto fail; | 124 | goto fail; |
128 | 125 | ||
129 | #ifdef CONFIG_MEMCG_SWAP | 126 | #ifdef CONFIG_MEMCG |
130 | dentry = debugfs_create_u64("corrupt-filter-memcg", 0600, | 127 | dentry = debugfs_create_u64("corrupt-filter-memcg", 0600, |
131 | hwpoison_dir, &hwpoison_filter_memcg); | 128 | hwpoison_dir, &hwpoison_filter_memcg); |
132 | if (!dentry) | 129 | if (!dentry) |
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index eeda6485e76c..95882692e747 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
@@ -130,27 +130,15 @@ static int hwpoison_filter_flags(struct page *p) | |||
130 | * can only guarantee that the page either belongs to the memcg tasks, or is | 130 | * can only guarantee that the page either belongs to the memcg tasks, or is |
131 | * a freed page. | 131 | * a freed page. |
132 | */ | 132 | */ |
133 | #ifdef CONFIG_MEMCG_SWAP | 133 | #ifdef CONFIG_MEMCG |
134 | u64 hwpoison_filter_memcg; | 134 | u64 hwpoison_filter_memcg; |
135 | EXPORT_SYMBOL_GPL(hwpoison_filter_memcg); | 135 | EXPORT_SYMBOL_GPL(hwpoison_filter_memcg); |
136 | static int hwpoison_filter_task(struct page *p) | 136 | static int hwpoison_filter_task(struct page *p) |
137 | { | 137 | { |
138 | struct mem_cgroup *mem; | ||
139 | struct cgroup_subsys_state *css; | ||
140 | unsigned long ino; | ||
141 | |||
142 | if (!hwpoison_filter_memcg) | 138 | if (!hwpoison_filter_memcg) |
143 | return 0; | 139 | return 0; |
144 | 140 | ||
145 | mem = try_get_mem_cgroup_from_page(p); | 141 | if (page_cgroup_ino(p) != hwpoison_filter_memcg) |
146 | if (!mem) | ||
147 | return -EINVAL; | ||
148 | |||
149 | css = &mem->css; | ||
150 | ino = cgroup_ino(css->cgroup); | ||
151 | css_put(css); | ||
152 | |||
153 | if (ino != hwpoison_filter_memcg) | ||
154 | return -EINVAL; | 142 | return -EINVAL; |
155 | 143 | ||
156 | return 0; | 144 | return 0; |