aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2016-01-20 18:02:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-20 20:09:18 -0500
commit0db1529817b7b16226421f01470c5ba982c5f302 (patch)
tree435a441507f45135160c670af9d24e9681c8425c /mm
parentd886f4e483ce63a3304adc9eda87031b93341c28 (diff)
mm: memcontrol: flatten struct cg_proto
There are no more external users of struct cg_proto, flatten the structure into struct mem_cgroup. Since using those struct members doesn't stand out as much anymore, add cgroup2 static branches to make it clearer which code is legacy. Suggested-by: Vladimir Davydov <vdavydov@virtuozzo.com> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: 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.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 379f9911b87b..6937f16f5ecb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2843,7 +2843,7 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
2843 counter = &memcg->kmem; 2843 counter = &memcg->kmem;
2844 break; 2844 break;
2845 case _TCP: 2845 case _TCP:
2846 counter = &memcg->tcp_mem.memory_allocated; 2846 counter = &memcg->tcpmem;
2847 break; 2847 break;
2848 default: 2848 default:
2849 BUG(); 2849 BUG();
@@ -3028,11 +3028,11 @@ static int memcg_update_tcp_limit(struct mem_cgroup *memcg, unsigned long limit)
3028 3028
3029 mutex_lock(&memcg_limit_mutex); 3029 mutex_lock(&memcg_limit_mutex);
3030 3030
3031 ret = page_counter_limit(&memcg->tcp_mem.memory_allocated, limit); 3031 ret = page_counter_limit(&memcg->tcpmem, limit);
3032 if (ret) 3032 if (ret)
3033 goto out; 3033 goto out;
3034 3034
3035 if (!memcg->tcp_mem.active) { 3035 if (!memcg->tcpmem_active) {
3036 /* 3036 /*
3037 * The active flag needs to be written after the static_key 3037 * The active flag needs to be written after the static_key
3038 * update. This is what guarantees that the socket activation 3038 * update. This is what guarantees that the socket activation
@@ -3050,7 +3050,7 @@ static int memcg_update_tcp_limit(struct mem_cgroup *memcg, unsigned long limit)
3050 * patched in yet. 3050 * patched in yet.
3051 */ 3051 */
3052 static_branch_inc(&memcg_sockets_enabled_key); 3052 static_branch_inc(&memcg_sockets_enabled_key);
3053 memcg->tcp_mem.active = true; 3053 memcg->tcpmem_active = true;
3054 } 3054 }
3055out: 3055out:
3056 mutex_unlock(&memcg_limit_mutex); 3056 mutex_unlock(&memcg_limit_mutex);
@@ -3119,7 +3119,7 @@ static ssize_t mem_cgroup_reset(struct kernfs_open_file *of, char *buf,
3119 counter = &memcg->kmem; 3119 counter = &memcg->kmem;
3120 break; 3120 break;
3121 case _TCP: 3121 case _TCP:
3122 counter = &memcg->tcp_mem.memory_allocated; 3122 counter = &memcg->tcpmem;
3123 break; 3123 break;
3124 default: 3124 default:
3125 BUG(); 3125 BUG();
@@ -4295,8 +4295,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
4295 memcg->soft_limit = PAGE_COUNTER_MAX; 4295 memcg->soft_limit = PAGE_COUNTER_MAX;
4296 page_counter_init(&memcg->memsw, &parent->memsw); 4296 page_counter_init(&memcg->memsw, &parent->memsw);
4297 page_counter_init(&memcg->kmem, &parent->kmem); 4297 page_counter_init(&memcg->kmem, &parent->kmem);
4298 page_counter_init(&memcg->tcp_mem.memory_allocated, 4298 page_counter_init(&memcg->tcpmem, &parent->tcpmem);
4299 &parent->tcp_mem.memory_allocated);
4300 4299
4301 /* 4300 /*
4302 * No need to take a reference to the parent because cgroup 4301 * No need to take a reference to the parent because cgroup
@@ -4308,7 +4307,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
4308 memcg->soft_limit = PAGE_COUNTER_MAX; 4307 memcg->soft_limit = PAGE_COUNTER_MAX;
4309 page_counter_init(&memcg->memsw, NULL); 4308 page_counter_init(&memcg->memsw, NULL);
4310 page_counter_init(&memcg->kmem, NULL); 4309 page_counter_init(&memcg->kmem, NULL);
4311 page_counter_init(&memcg->tcp_mem.memory_allocated, NULL); 4310 page_counter_init(&memcg->tcpmem, NULL);
4312 /* 4311 /*
4313 * Deeper hierachy with use_hierarchy == false doesn't make 4312 * Deeper hierachy with use_hierarchy == false doesn't make
4314 * much sense so let cgroup subsystem know about this 4313 * much sense so let cgroup subsystem know about this
@@ -4374,7 +4373,7 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
4374 if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket) 4373 if (cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgroup_memory_nosocket)
4375 static_branch_dec(&memcg_sockets_enabled_key); 4374 static_branch_dec(&memcg_sockets_enabled_key);
4376 4375
4377 if (memcg->tcp_mem.active) 4376 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg->tcpmem_active)
4378 static_branch_dec(&memcg_sockets_enabled_key); 4377 static_branch_dec(&memcg_sockets_enabled_key);
4379 4378
4380 memcg_free_kmem(memcg); 4379 memcg_free_kmem(memcg);
@@ -5601,7 +5600,7 @@ void sock_update_memcg(struct sock *sk)
5601 memcg = mem_cgroup_from_task(current); 5600 memcg = mem_cgroup_from_task(current);
5602 if (memcg == root_mem_cgroup) 5601 if (memcg == root_mem_cgroup)
5603 goto out; 5602 goto out;
5604 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcp_mem.active) 5603 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcpmem_active)
5605 goto out; 5604 goto out;
5606 if (css_tryget_online(&memcg->css)) 5605 if (css_tryget_online(&memcg->css))
5607 sk->sk_memcg = memcg; 5606 sk->sk_memcg = memcg;
@@ -5629,15 +5628,14 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5629 gfp_t gfp_mask = GFP_KERNEL; 5628 gfp_t gfp_mask = GFP_KERNEL;
5630 5629
5631 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) { 5630 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
5632 struct page_counter *counter; 5631 struct page_counter *fail;
5633 5632
5634 if (page_counter_try_charge(&memcg->tcp_mem.memory_allocated, 5633 if (page_counter_try_charge(&memcg->tcpmem, nr_pages, &fail)) {
5635 nr_pages, &counter)) { 5634 memcg->tcpmem_pressure = 0;
5636 memcg->tcp_mem.memory_pressure = 0;
5637 return true; 5635 return true;
5638 } 5636 }
5639 page_counter_charge(&memcg->tcp_mem.memory_allocated, nr_pages); 5637 page_counter_charge(&memcg->tcpmem, nr_pages);
5640 memcg->tcp_mem.memory_pressure = 1; 5638 memcg->tcpmem_pressure = 1;
5641 return false; 5639 return false;
5642 } 5640 }
5643 5641
@@ -5660,8 +5658,7 @@ bool mem_cgroup_charge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5660void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages) 5658void mem_cgroup_uncharge_skmem(struct mem_cgroup *memcg, unsigned int nr_pages)
5661{ 5659{
5662 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) { 5660 if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
5663 page_counter_uncharge(&memcg->tcp_mem.memory_allocated, 5661 page_counter_uncharge(&memcg->tcpmem, nr_pages);
5664 nr_pages);
5665 return; 5662 return;
5666 } 5663 }
5667 5664