[PATCH v6 29/31] memcg: move initialization to memcg creation

Glauber Costa
2013-05-12T18:13:50Z

Those structures are only used for memcgs that are effectively using
kmemcg. However, in a later patch I intend to use scan that list
inconditionally (list empty meaning no kmem caches present), which
simplifies the code a lot.

So move the initialization to early kmem creation.

Signed-off-by: Glauber Costa <glommer@openvz.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
mm/memcontrol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index b8980d1..6f6a330 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3323,9 +3323,7 @@ int memcg_update_cache_sizes(struct mem_cgroup *memcg)

memcg_update_array_size(num + 1);

- INIT_LIST_HEAD(&memcg->memcg_slab_caches);
INIT_WORK(&memcg->kmemcg_shrink_work, kmemcg_shrink_work_fn);
- mutex_init(&memcg->slab_caches_mutex);

return 0;
out:
@@ -6318,6 +6316,8 @@ static int memcg_init_kmem(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
{
int ret;

+ INIT_LIST_HEAD(&memcg->memcg_slab_caches);
+ mutex_init(&memcg->slab_caches_mutex);
memcg->kmemcg_id = -1;
ret = memcg_propagate_kmem(memcg);
if (ret)
--
1.8.1.4