summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2014-12-12 19:55:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 15:42:46 -0500
commit900a38f027b37b55ebe157a0cb31de351b91e4e2 (patch)
tree147390438f5775f12909dad348b0126c6d27cd70
parentc313dc5dedbc9b51bb7a77959ffbda44712ac2e1 (diff)
memcg: zap kmem_account_flags
The only such flag is KMEM_ACCOUNTED_ACTIVE, but it's set iff mem_cgroup->kmemcg_id is initialized, so we can check kmemcg_id instead of having a separate flags field. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Cc: 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>
-rw-r--r--mm/memcontrol.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 5a27e224d561..bb8c237026cc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -296,7 +296,6 @@ struct mem_cgroup {
296 * Should the accounting and control be hierarchical, per subtree? 296 * Should the accounting and control be hierarchical, per subtree?
297 */ 297 */
298 bool use_hierarchy; 298 bool use_hierarchy;
299 unsigned long kmem_account_flags; /* See KMEM_ACCOUNTED_*, below */
300 299
301 bool oom_lock; 300 bool oom_lock;
302 atomic_t under_oom; 301 atomic_t under_oom;
@@ -366,22 +365,11 @@ struct mem_cgroup {
366 /* WARNING: nodeinfo must be the last member here */ 365 /* WARNING: nodeinfo must be the last member here */
367}; 366};
368 367
369/* internal only representation about the status of kmem accounting. */
370enum {
371 KMEM_ACCOUNTED_ACTIVE, /* accounted by this cgroup itself */
372};
373
374#ifdef CONFIG_MEMCG_KMEM 368#ifdef CONFIG_MEMCG_KMEM
375static inline void memcg_kmem_set_active(struct mem_cgroup *memcg)
376{
377 set_bit(KMEM_ACCOUNTED_ACTIVE, &memcg->kmem_account_flags);
378}
379
380static bool memcg_kmem_is_active(struct mem_cgroup *memcg) 369static bool memcg_kmem_is_active(struct mem_cgroup *memcg)
381{ 370{
382 return test_bit(KMEM_ACCOUNTED_ACTIVE, &memcg->kmem_account_flags); 371 return memcg->kmemcg_id >= 0;
383} 372}
384
385#endif 373#endif
386 374
387/* Stuffs for move charges at task migration. */ 375/* Stuffs for move charges at task migration. */
@@ -3564,23 +3552,21 @@ static int memcg_activate_kmem(struct mem_cgroup *memcg,
3564 goto out; 3552 goto out;
3565 } 3553 }
3566 3554
3567 memcg->kmemcg_id = memcg_id;
3568 INIT_LIST_HEAD(&memcg->memcg_slab_caches);
3569
3570 /* 3555 /*
3571 * We couldn't have accounted to this cgroup, because it hasn't got the 3556 * We couldn't have accounted to this cgroup, because it hasn't got
3572 * active bit set yet, so this should succeed. 3557 * activated yet, so this should succeed.
3573 */ 3558 */
3574 err = page_counter_limit(&memcg->kmem, nr_pages); 3559 err = page_counter_limit(&memcg->kmem, nr_pages);
3575 VM_BUG_ON(err); 3560 VM_BUG_ON(err);
3576 3561
3577 static_key_slow_inc(&memcg_kmem_enabled_key); 3562 static_key_slow_inc(&memcg_kmem_enabled_key);
3578 /* 3563 /*
3579 * Setting the active bit after enabling static branching will 3564 * A memory cgroup is considered kmem-active as soon as it gets
3565 * kmemcg_id. Setting the id after enabling static branching will
3580 * guarantee no one starts accounting before all call sites are 3566 * guarantee no one starts accounting before all call sites are
3581 * patched. 3567 * patched.
3582 */ 3568 */
3583 memcg_kmem_set_active(memcg); 3569 memcg->kmemcg_id = memcg_id;
3584out: 3570out:
3585 return err; 3571 return err;
3586} 3572}
@@ -4252,7 +4238,6 @@ static int memcg_init_kmem(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
4252{ 4238{
4253 int ret; 4239 int ret;
4254 4240
4255 memcg->kmemcg_id = -1;
4256 ret = memcg_propagate_kmem(memcg); 4241 ret = memcg_propagate_kmem(memcg);
4257 if (ret) 4242 if (ret)
4258 return ret; 4243 return ret;
@@ -4786,6 +4771,10 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
4786 vmpressure_init(&memcg->vmpressure); 4771 vmpressure_init(&memcg->vmpressure);
4787 INIT_LIST_HEAD(&memcg->event_list); 4772 INIT_LIST_HEAD(&memcg->event_list);
4788 spin_lock_init(&memcg->event_list_lock); 4773 spin_lock_init(&memcg->event_list_lock);
4774#ifdef CONFIG_MEMCG_KMEM
4775 memcg->kmemcg_id = -1;
4776 INIT_LIST_HEAD(&memcg->memcg_slab_caches);
4777#endif
4789 4778
4790 return &memcg->css; 4779 return &memcg->css;
4791 4780