diff options
author | Li Zefan <lizefan@huawei.com> | 2013-07-08 19:00:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-09 13:33:24 -0400 |
commit | 5347e5ae13710420eebbbd0b22c045685704da80 (patch) | |
tree | 61bc244a9938a28e7a1f96d2d7fb0c3dc8ac486b /mm | |
parent | f37a96914d1aea10fed8d9af10251f0b9caea31b (diff) |
memcg: use css_get() in sock_update_memcg()
Use css_get/css_put instead of mem_cgroup_get/put.
Note, if at the same time someone is moving @current to a different
cgroup and removing the old cgroup, css_tryget() may return false, and
sock->sk_cgrp won't be initialized, which is fine.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
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.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index bdeb82ca6c20..4c31a21a55be 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -551,15 +551,15 @@ void sock_update_memcg(struct sock *sk) | |||
551 | */ | 551 | */ |
552 | if (sk->sk_cgrp) { | 552 | if (sk->sk_cgrp) { |
553 | BUG_ON(mem_cgroup_is_root(sk->sk_cgrp->memcg)); | 553 | BUG_ON(mem_cgroup_is_root(sk->sk_cgrp->memcg)); |
554 | mem_cgroup_get(sk->sk_cgrp->memcg); | 554 | css_get(&sk->sk_cgrp->memcg->css); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | 557 | ||
558 | rcu_read_lock(); | 558 | rcu_read_lock(); |
559 | memcg = mem_cgroup_from_task(current); | 559 | memcg = mem_cgroup_from_task(current); |
560 | cg_proto = sk->sk_prot->proto_cgroup(memcg); | 560 | cg_proto = sk->sk_prot->proto_cgroup(memcg); |
561 | if (!mem_cgroup_is_root(memcg) && memcg_proto_active(cg_proto)) { | 561 | if (!mem_cgroup_is_root(memcg) && |
562 | mem_cgroup_get(memcg); | 562 | memcg_proto_active(cg_proto) && css_tryget(&memcg->css)) { |
563 | sk->sk_cgrp = cg_proto; | 563 | sk->sk_cgrp = cg_proto; |
564 | } | 564 | } |
565 | rcu_read_unlock(); | 565 | rcu_read_unlock(); |
@@ -573,7 +573,7 @@ void sock_release_memcg(struct sock *sk) | |||
573 | struct mem_cgroup *memcg; | 573 | struct mem_cgroup *memcg; |
574 | WARN_ON(!sk->sk_cgrp->memcg); | 574 | WARN_ON(!sk->sk_cgrp->memcg); |
575 | memcg = sk->sk_cgrp->memcg; | 575 | memcg = sk->sk_cgrp->memcg; |
576 | mem_cgroup_put(memcg); | 576 | css_put(&sk->sk_cgrp->memcg->css); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||