aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLi Zefan <lizefan@huawei.com>2013-07-08 19:00:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:24 -0400
commit8d76a9797882fc517d87e2b5db2a4f04edaeccec (patch)
treea815aca84438215643689cc3687db1ba003d4298 /mm
parent4050377b509b326c14b275fedb2f69b46f37a7a9 (diff)
memcg: don't need to get a reference to the parent
The cgroup core guarantees it's always safe to access the parent. Signed-off-by: Li Zefan <lizefan@huawei.com> Acked-by: Michal Hocko <mhocko@suse.cz> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Hugh Dickins <hughd@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Glauber Costa <glommer@openvz.org> Cc: Johannes Weiner <hannes@cmpxchg.org> 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/memcontrol.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 76c0c99b002f..c508258d61a1 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -503,7 +503,6 @@ enum res_type {
503 */ 503 */
504static DEFINE_MUTEX(memcg_create_mutex); 504static DEFINE_MUTEX(memcg_create_mutex);
505 505
506static void mem_cgroup_get(struct mem_cgroup *memcg);
507static void mem_cgroup_put(struct mem_cgroup *memcg); 506static void mem_cgroup_put(struct mem_cgroup *memcg);
508 507
509static inline 508static inline
@@ -6239,19 +6238,10 @@ static void free_rcu(struct rcu_head *rcu_head)
6239 schedule_work(&memcg->work_freeing); 6238 schedule_work(&memcg->work_freeing);
6240} 6239}
6241 6240
6242static void mem_cgroup_get(struct mem_cgroup *memcg)
6243{
6244 atomic_inc(&memcg->refcnt);
6245}
6246
6247static void __mem_cgroup_put(struct mem_cgroup *memcg, int count) 6241static void __mem_cgroup_put(struct mem_cgroup *memcg, int count)
6248{ 6242{
6249 if (atomic_sub_and_test(count, &memcg->refcnt)) { 6243 if (atomic_sub_and_test(count, &memcg->refcnt))
6250 struct mem_cgroup *parent = parent_mem_cgroup(memcg);
6251 call_rcu(&memcg->rcu_freeing, free_rcu); 6244 call_rcu(&memcg->rcu_freeing, free_rcu);
6252 if (parent)
6253 mem_cgroup_put(parent);
6254 }
6255} 6245}
6256 6246
6257static void mem_cgroup_put(struct mem_cgroup *memcg) 6247static void mem_cgroup_put(struct mem_cgroup *memcg)
@@ -6354,12 +6344,9 @@ mem_cgroup_css_online(struct cgroup *cont)
6354 res_counter_init(&memcg->kmem, &parent->kmem); 6344 res_counter_init(&memcg->kmem, &parent->kmem);
6355 6345
6356 /* 6346 /*
6357 * We increment refcnt of the parent to ensure that we can 6347 * No need to take a reference to the parent because cgroup
6358 * safely access it on res_counter_charge/uncharge. 6348 * core guarantees its existence.
6359 * This refcnt will be decremented when freeing this
6360 * mem_cgroup(see mem_cgroup_put).
6361 */ 6349 */
6362 mem_cgroup_get(parent);
6363 } else { 6350 } else {
6364 res_counter_init(&memcg->res, NULL); 6351 res_counter_init(&memcg->res, NULL);
6365 res_counter_init(&memcg->memsw, NULL); 6352 res_counter_init(&memcg->memsw, NULL);