aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-10-07 20:00:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-07 21:46:29 -0400
commit2d75807383459c04d457bf2d295fa6ad858507d2 (patch)
tree66463e88f69356ec92d59d1c8416b076181970e6 /mm
parent08ea8c07fb56d6eb8194d8ad408b469544bf2c29 (diff)
mm: memcontrol: consolidate cgroup socket tracking
The cgroup core and the memory controller need to track socket ownership for different purposes, but the tracking sites being entirely different is kind of ugly. Be a better citizen and rename the memory controller callbacks to match the cgroup core callbacks, then move them to the same place. [akpm@linux-foundation.org: coding-style fixes] Link: http://lkml.kernel.org/r/20160914194846.11153-3-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Tejun Heo <tj@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Michal Hocko <mhocko@suse.cz> Cc: Vladimir Davydov <vdavydov@virtuozzo.com> 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.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 60bb830abc34..ae052b5e3315 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2939,16 +2939,16 @@ static int memcg_update_tcp_limit(struct mem_cgroup *memcg, unsigned long limit)
2939 /* 2939 /*
2940 * The active flag needs to be written after the static_key 2940 * The active flag needs to be written after the static_key
2941 * update. This is what guarantees that the socket activation 2941 * update. This is what guarantees that the socket activation
2942 * function is the last one to run. See sock_update_memcg() for 2942 * function is the last one to run. See mem_cgroup_sk_alloc()
2943 * details, and note that we don't mark any socket as belonging 2943 * for details, and note that we don't mark any socket as
2944 * to this memcg until that flag is up. 2944 * belonging to this memcg until that flag is up.
2945 * 2945 *
2946 * We need to do this, because static_keys will span multiple 2946 * We need to do this, because static_keys will span multiple
2947 * sites, but we can't control their order. If we mark a socket 2947 * sites, but we can't control their order. If we mark a socket
2948 * as accounted, but the accounting functions are not patched in 2948 * as accounted, but the accounting functions are not patched in
2949 * yet, we'll lose accounting. 2949 * yet, we'll lose accounting.
2950 * 2950 *
2951 * We never race with the readers in sock_update_memcg(), 2951 * We never race with the readers in mem_cgroup_sk_alloc(),
2952 * because when this value change, the code to process it is not 2952 * because when this value change, the code to process it is not
2953 * patched in yet. 2953 * patched in yet.
2954 */ 2954 */
@@ -5651,11 +5651,15 @@ void mem_cgroup_migrate(struct page *oldpage, struct page *newpage)
5651DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key); 5651DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key);
5652EXPORT_SYMBOL(memcg_sockets_enabled_key); 5652EXPORT_SYMBOL(memcg_sockets_enabled_key);
5653 5653
5654void sock_update_memcg(struct sock *sk) 5654void mem_cgroup_sk_alloc(struct sock *sk)
5655{ 5655{
5656 struct mem_cgroup *memcg; 5656 struct mem_cgroup *memcg;
5657 5657
5658 /* Socket cloning can throw us here with sk_cgrp already 5658 if (!mem_cgroup_sockets_enabled)
5659 return;
5660
5661 /*
5662 * Socket cloning can throw us here with sk_memcg already
5659 * filled. It won't however, necessarily happen from 5663 * filled. It won't however, necessarily happen from
5660 * process context. So the test for root memcg given 5664 * process context. So the test for root memcg given
5661 * the current task's memcg won't help us in this case. 5665 * the current task's memcg won't help us in this case.
@@ -5680,12 +5684,11 @@ void sock_update_memcg(struct sock *sk)
5680out: 5684out:
5681 rcu_read_unlock(); 5685 rcu_read_unlock();
5682} 5686}
5683EXPORT_SYMBOL(sock_update_memcg);
5684 5687
5685void sock_release_memcg(struct sock *sk) 5688void mem_cgroup_sk_free(struct sock *sk)
5686{ 5689{
5687 WARN_ON(!sk->sk_memcg); 5690 if (sk->sk_memcg)
5688 css_put(&sk->sk_memcg->css); 5691 css_put(&sk->sk_memcg->css);
5689} 5692}
5690 5693
5691/** 5694/**