]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memcg: move memcg_stock initialization to mem_cgroup_init
authorMichal Hocko <mhocko@suse.cz>
Thu, 7 Feb 2013 01:27:10 +0000 (12:27 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:46:53 +0000 (16:46 +1100)
memcg_stock are currently initialized during the root cgroup allocation
which is OK but it pointlessly pollutes memcg allocation code with
something that can be called when the memcg subsystem is initialized by
mem_cgroup_init along with other controller specific parts.

This patch wraps the current memcg_stock initialization code into a helper
calls it from the controller subsystem initialization code.

Signed-off-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tejun Heo <htejun@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index 77e272c5ccd4f5b4e031d5e64ca627f3e4a9d733..5a70a19339619754288e7d156b9fee98ba0cfe20 100644 (file)
@@ -2296,6 +2296,17 @@ static void drain_local_stock(struct work_struct *dummy)
        clear_bit(FLUSHING_CACHED_CHARGE, &stock->flags);
 }
 
+static void __init memcg_stock_init(void)
+{
+       int cpu;
+
+       for_each_possible_cpu(cpu) {
+               struct memcg_stock_pcp *stock =
+                                       &per_cpu(memcg_stock, cpu);
+               INIT_WORK(&stock->work, drain_local_stock);
+       }
+}
+
 /*
  * Cache charges(val) which is from res_counter, to local per_cpu area.
  * This will be consumed by consume_stock() function, later.
@@ -6093,15 +6104,7 @@ mem_cgroup_css_alloc(struct cgroup *cont)
 
        /* root ? */
        if (cont->parent == NULL) {
-               int cpu;
-
                root_mem_cgroup = memcg;
-               for_each_possible_cpu(cpu) {
-                       struct memcg_stock_pcp *stock =
-                                               &per_cpu(memcg_stock, cpu);
-                       INIT_WORK(&stock->work, drain_local_stock);
-               }
-
                res_counter_init(&memcg->res, NULL);
                res_counter_init(&memcg->memsw, NULL);
                res_counter_init(&memcg->kmem, NULL);
@@ -6838,6 +6841,7 @@ static int __init mem_cgroup_init(void)
        hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
        enable_swap_cgroup();
        mem_cgroup_soft_limit_tree_init();
+       memcg_stock_init();
        return 0;
 }
 subsys_initcall(mem_cgroup_init);