aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2014-10-09 18:28:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:26:00 -0400
commitcf2b8fbf1d2f7ba07999e97685563c94483d33d6 (patch)
tree0796234b347896da6b7a2c3fee67b4b2bfb52278 /mm/memcontrol.c
parentb70a2a21dc9d4ad455931b53131a0cb4fc01fafe (diff)
memcg: zap memcg_can_account_kmem
memcg_can_account_kmem() returns true iff !mem_cgroup_disabled() && !mem_cgroup_is_root(memcg) && memcg_kmem_is_active(memcg); To begin with the !mem_cgroup_is_root(memcg) check is useless, because one can't enable kmem accounting for the root cgroup (mem_cgroup_write() returns EINVAL on an attempt to set the limit on the root cgroup). Furthermore, the !mem_cgroup_disabled() check also seems to be redundant. The point is memcg_can_account_kmem() is called from three places: mem_cgroup_salbinfo_read(), __memcg_kmem_get_cache(), and __memcg_kmem_newpage_charge(). The latter two functions are only invoked if memcg_kmem_enabled() returns true, which implies that the memory cgroup subsystem is enabled. And mem_cgroup_slabinfo_read() shows the output of memory.kmem.slabinfo, which won't exist if the memory cgroup is completely disabled. So let's substitute all the calls to memcg_can_account_kmem() with plain memcg_kmem_is_active(), and kill the former. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c86cc442ada4..23976fd885fd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2762,12 +2762,6 @@ static DEFINE_MUTEX(memcg_slab_mutex);
2762 2762
2763static DEFINE_MUTEX(activate_kmem_mutex); 2763static DEFINE_MUTEX(activate_kmem_mutex);
2764 2764
2765static inline bool memcg_can_account_kmem(struct mem_cgroup *memcg)
2766{
2767 return !mem_cgroup_disabled() && !mem_cgroup_is_root(memcg) &&
2768 memcg_kmem_is_active(memcg);
2769}
2770
2771/* 2765/*
2772 * This is a bit cumbersome, but it is rarely used and avoids a backpointer 2766 * This is a bit cumbersome, but it is rarely used and avoids a backpointer
2773 * in the memcg_cache_params struct. 2767 * in the memcg_cache_params struct.
@@ -2787,7 +2781,7 @@ static int mem_cgroup_slabinfo_read(struct seq_file *m, void *v)
2787 struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); 2781 struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m));
2788 struct memcg_cache_params *params; 2782 struct memcg_cache_params *params;
2789 2783
2790 if (!memcg_can_account_kmem(memcg)) 2784 if (!memcg_kmem_is_active(memcg))
2791 return -EIO; 2785 return -EIO;
2792 2786
2793 print_slabinfo_header(m); 2787 print_slabinfo_header(m);
@@ -3164,7 +3158,7 @@ struct kmem_cache *__memcg_kmem_get_cache(struct kmem_cache *cachep,
3164 rcu_read_lock(); 3158 rcu_read_lock();
3165 memcg = mem_cgroup_from_task(rcu_dereference(current->mm->owner)); 3159 memcg = mem_cgroup_from_task(rcu_dereference(current->mm->owner));
3166 3160
3167 if (!memcg_can_account_kmem(memcg)) 3161 if (!memcg_kmem_is_active(memcg))
3168 goto out; 3162 goto out;
3169 3163
3170 memcg_cachep = cache_from_memcg_idx(cachep, memcg_cache_id(memcg)); 3164 memcg_cachep = cache_from_memcg_idx(cachep, memcg_cache_id(memcg));
@@ -3249,7 +3243,7 @@ __memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **_memcg, int order)
3249 3243
3250 memcg = get_mem_cgroup_from_mm(current->mm); 3244 memcg = get_mem_cgroup_from_mm(current->mm);
3251 3245
3252 if (!memcg_can_account_kmem(memcg)) { 3246 if (!memcg_kmem_is_active(memcg)) {
3253 css_put(&memcg->css); 3247 css_put(&memcg->css);
3254 return true; 3248 return true;
3255 } 3249 }