Skip to content

Commit

Permalink
hwpoison: use page_cgroup_ino for filtering by memcg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Andres Lagar-Cavilla <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Raghavendra K T <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Greg Thelen <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Cyrill Gorcunov <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Vladimir Davydov authored and torvalds committed Sep 10, 2015
1 parent 2fc0452 commit 94a59fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
5 changes: 1 addition & 4 deletions mm/hwpoison-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ static int hwpoison_inject(void *data, u64 val)
/*
* do a racy check with elevated page count, to make sure PG_hwpoison
* will only be set for the targeted owner (or on a free page).
* We temporarily take page lock for try_get_mem_cgroup_from_page().
* memory_failure() will redo the check reliably inside page lock.
*/
lock_page(hpage);
err = hwpoison_filter(hpage);
unlock_page(hpage);
if (err)
goto put_out;

Expand Down Expand Up @@ -126,7 +123,7 @@ static int pfn_inject_init(void)
if (!dentry)
goto fail;

#ifdef CONFIG_MEMCG_SWAP
#ifdef CONFIG_MEMCG
dentry = debugfs_create_u64("corrupt-filter-memcg", 0600,
hwpoison_dir, &hwpoison_filter_memcg);
if (!dentry)
Expand Down
16 changes: 2 additions & 14 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,15 @@ static int hwpoison_filter_flags(struct page *p)
* can only guarantee that the page either belongs to the memcg tasks, or is
* a freed page.
*/
#ifdef CONFIG_MEMCG_SWAP
#ifdef CONFIG_MEMCG
u64 hwpoison_filter_memcg;
EXPORT_SYMBOL_GPL(hwpoison_filter_memcg);
static int hwpoison_filter_task(struct page *p)
{
struct mem_cgroup *mem;
struct cgroup_subsys_state *css;
unsigned long ino;

if (!hwpoison_filter_memcg)
return 0;

mem = try_get_mem_cgroup_from_page(p);
if (!mem)
return -EINVAL;

css = &mem->css;
ino = cgroup_ino(css->cgroup);
css_put(css);

if (ino != hwpoison_filter_memcg)
if (page_cgroup_ino(p) != hwpoison_filter_memcg)
return -EINVAL;

return 0;
Expand Down

0 comments on commit 94a59fb

Please sign in to comment.