[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1342580730-25703-1-git-send-email-liwanp@linux.vnet.ibm.com>
Date: Wed, 18 Jul 2012 11:05:30 +0800
From: Wanpeng Li <liwanp@...ux.vnet.ibm.com>
To: linux-mm@...ck.org
Cc: Wanpeng Li <liwanp@...ux.vnet.ibm.com>,
Michal Hocko <mhocko@...e.cz>,
Johannes Weiner <hannes@...xchg.org>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Gavin Shan <shangw@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] mm/memcg: wrap mem_cgroup_from_css function
wrap mem_cgroup_from_css function to clarify get mem cgroup
from cgroup_subsys_state.
Signed-off-by: Wanpeng Li <liwanp@...ux.vnet.ibm.com>
Cc: Michal Hocko <mhocko@...e.cz>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Gavin Shan <shangw@...ux.vnet.ibm.com>
Cc: Wanpeng Li <liwanp@...ux.vnet.ibm.com>
Cc: linux-kernel@...r.kernel.org
---
mm/memcontrol.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 58a08fc..20f6a15 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -396,6 +396,12 @@ static void mem_cgroup_put(struct mem_cgroup *memcg);
#include <net/sock.h>
#include <net/ip.h>
+static inline
+struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *s)
+{
+ return container_of(s, struct mem_cgroup, css);
+}
+
static bool mem_cgroup_is_root(struct mem_cgroup *memcg);
void sock_update_memcg(struct sock *sk)
{
@@ -820,7 +826,7 @@ static void memcg_check_events(struct mem_cgroup *memcg, struct page *page)
struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont)
{
- return container_of(cgroup_subsys_state(cont,
+ return mem_cgroup_from_css(cgroup_subsys_state(cont,
mem_cgroup_subsys_id), struct mem_cgroup,
css);
}
@@ -835,7 +841,7 @@ struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
if (unlikely(!p))
return NULL;
- return container_of(task_subsys_state(p, mem_cgroup_subsys_id),
+ return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id),
struct mem_cgroup, css);
}
@@ -922,7 +928,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
css = css_get_next(&mem_cgroup_subsys, id + 1, &root->css, &id);
if (css) {
if (css == &root->css || css_tryget(css))
- memcg = container_of(css,
+ memcg = mem_cgroup_from_css(css,
struct mem_cgroup, css);
} else
id = 0;
@@ -2406,7 +2412,7 @@ static struct mem_cgroup *mem_cgroup_lookup(unsigned short id)
css = css_lookup(&mem_cgroup_subsys, id);
if (!css)
return NULL;
- return container_of(css, struct mem_cgroup, css);
+ return mem_cgroup_from_css(css, struct mem_cgroup, css);
}
struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists