Mainstream has been updated since we pulled this feature. Need to pull it again.
This reverts commit 6172d4169bb5f6404535cddf66bd1c79e81e7908. --- include/linux/memcontrol.h | 3 --- mm/hwpoison-inject.c | 3 +++ mm/memcontrol.c | 22 ---------------------- mm/memory-failure.c | 18 +++++++++++++++++- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 5835c8ca199d..2aa914b3f8ec 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -216,9 +216,6 @@ void mem_cgroup_split_huge_fixup(struct page *head); bool mem_cgroup_bad_page_check(struct page *page); void mem_cgroup_print_bad_page(struct page *page); #endif - -unsigned long page_cgroup_ino(struct page *page); - #else /* CONFIG_MEMCG */ struct mem_cgroup; diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c index bd580f803f5c..3a61efc518d5 100644 --- a/mm/hwpoison-inject.c +++ b/mm/hwpoison-inject.c @@ -44,9 +44,12 @@ 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) return 0; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 234ed8de3f85..9c38592b55f6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2996,28 +2996,6 @@ struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page) return memcg; } -/** - * page_cgroup_ino - return inode number of page's memcg - * @page: the page - * - * Look up the memory cgroup @page is charged to and return its inode number. - * It is safe to call this function without taking a reference to the page. - */ -unsigned long page_cgroup_ino(struct page *page) -{ - struct mem_cgroup *memcg; - struct page_cgroup *pc; - unsigned long ino = 0; - - pc = lookup_page_cgroup(page); - lock_page_cgroup(pc); - memcg = pc->mem_cgroup; - if (PageCgroupUsed(pc) && memcg) - ino = memcg->css.cgroup->dentry->d_inode->i_ino; - unlock_page_cgroup(pc); - return ino; -} - static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg, struct page *page, unsigned int nr_pages, diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c4d2c160d64d..a565e7283ae8 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -133,10 +133,26 @@ 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; - if (page_cgroup_ino(p) != hwpoison_filter_memcg) + mem = try_get_mem_cgroup_from_page(p); + if (!mem) + return -EINVAL; + + css = mem_cgroup_css(mem); + /* root_mem_cgroup has NULL dentries */ + if (!css->cgroup->dentry) + return -EINVAL; + + ino = css->cgroup->dentry->d_inode->i_ino; + css_put(css); + + if (ino != hwpoison_filter_memcg) return -EINVAL; return 0; -- 2.1.4 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel