[Devel] [PATCH RHEL7 COMMIT] Revert "ms/memcg: add page_cgroup_ino helper"

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 5 05:36:22 PST 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.6
------>
commit 54525c037d6cead3c7419938c047797485f193b5
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Thu Nov 5 17:36:22 2015 +0400

    Revert "ms/memcg: add page_cgroup_ino helper"
    
    https://jira.sw.ru/browse/PSBM-32460
    
    Mainstream has been updated since we pulled this feature. Need to pull
    it again.
    
    This reverts commit 6172d4169bb5f6404535cddf66bd1c79e81e7908.
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 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 5835c8c..2aa914b 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 bd580f8..3a61efc 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 234ed8d..9c38592 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 c4d2c16..a565e72 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;



More information about the Devel mailing list