Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1184699

[PATCH 5/5] memcg, tcp_kmem: check for cg_proto in sock_update_memcg

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 5/5] memcg, tcp_kmem: check for cg_proto in sock_update_memcg
Date 2015-07-15 13:20 +0200
Message-ID <pMsTh-5QQ-39@gated-at.bofh.it> (permalink)
References <pMsTf-5QQ-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Michal Hocko <mhocko@suse.cz>

sk_prot->proto_cgroup is allowed to return NULL but sock_update_memcg
doesn't check for NULL. The function relies on the mem_cgroup_is_root
check because we shouldn't get NULL otherwise because
mem_cgroup_from_task will always return !NULL.

All other callers are checking for NULL and we can safely replace
mem_cgroup_is_root() check by cg_proto != NULL which will be more
straightforward (proto_cgroup returns NULL for the root memcg already).

Reviewed-by: Vladimir Davydov <vdavydov@parallels.com>
Signed-off-by: Michal Hocko <mhocko@suse.cz>
---
 mm/memcontrol.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5d4fba8cbdd0..cf9fb1f41831 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -315,8 +315,7 @@ void sock_update_memcg(struct sock *sk)
 		rcu_read_lock();
 		memcg = mem_cgroup_from_task(current);
 		cg_proto = sk->sk_prot->proto_cgroup(memcg);
-		if (!mem_cgroup_is_root(memcg) &&
-		    memcg_proto_active(cg_proto) &&
+		if (cg_proto && memcg_proto_active(cg_proto) &&
 		    css_tryget_online(&memcg->css)) {
 			sk->sk_cgrp = cg_proto;
 		}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] expose mem_cgroup + cleanups Michal Hocko <mhocko@kernel.org> - 2015-07-15 13:20 +0200
  [PATCH 3/5] memcg: get rid of extern for functions in memcontrol.h Michal Hocko <mhocko@kernel.org> - 2015-07-15 13:20 +0200
  [PATCH 2/5] memcg: get rid of mem_cgroup_root_css for !CONFIG_MEMCG Michal Hocko <mhocko@kernel.org> - 2015-07-15 13:20 +0200
  [PATCH 5/5] memcg, tcp_kmem: check for cg_proto in sock_update_memcg Michal Hocko <mhocko@kernel.org> - 2015-07-15 13:20 +0200
  Re: [PATCH 1/5] memcg: export struct mem_cgroup Andrew Morton <akpm@linux-foundation.org> - 2015-07-15 23:00 +0200
    Re: [PATCH 1/5] memcg: export struct mem_cgroup Andrew Morton <akpm@linux-foundation.org> - 2015-07-16 23:40 +0200
      Re: [PATCH 1/5] memcg: export struct mem_cgroup Johannes Weiner <hannes@cmpxchg.org> - 2015-07-17 01:00 +0200
        Re: [PATCH 1/5] memcg: export struct mem_cgroup Andrew Morton <akpm@linux-foundation.org> - 2015-07-17 01:10 +0200
          Re: [PATCH 1/5] memcg: export struct mem_cgroup Johannes Weiner <hannes@cmpxchg.org> - 2015-07-17 14:30 +0200

csiph-web