Merge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb...
[deliverable/linux.git] / mm / memcontrol.c
index bb894b071f59a131453daaa8f0dda315633f77eb..53b8201b31eb6f21bf66a3ca26f07fbf39f21c65 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.
@@ -5014,6 +5025,7 @@ out:
        return ret;
 }
 
+#ifdef CONFIG_MEMCG_KMEM
 static int memcg_propagate_kmem(struct mem_cgroup *memcg)
 {
        int ret = 0;
@@ -5022,7 +5034,6 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
                goto out;
 
        memcg->kmem_account_flags = parent->kmem_account_flags;
-#ifdef CONFIG_MEMCG_KMEM
        /*
         * When that happen, we need to disable the static branch only on those
         * memcgs that enabled it. To achieve this, we would be forced to
@@ -5048,10 +5059,10 @@ static int memcg_propagate_kmem(struct mem_cgroup *memcg)
        mutex_lock(&set_limit_mutex);
        ret = memcg_update_cache_sizes(memcg);
        mutex_unlock(&set_limit_mutex);
-#endif
 out:
        return ret;
 }
+#endif /* CONFIG_MEMCG_KMEM */
 
 /*
  * The user of this function is...
@@ -6092,15 +6103,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);
@@ -6827,16 +6830,19 @@ static void __init enable_swap_cgroup(void)
 #endif
 
 /*
- * The rest of init is performed during ->css_alloc() for root css which
- * happens before initcalls.  hotcpu_notifier() can't be done together as
- * it would introduce circular locking by adding cgroup_lock -> cpu hotplug
- * dependency.  Do it from a subsys_initcall().
+ * subsys_initcall() for memory controller.
+ *
+ * Some parts like hotcpu_notifier() have to be initialized from this context
+ * because of lock dependencies (cgroup_lock -> cpu hotplug) but basically
+ * everything that doesn't depend on a specific mem_cgroup structure should
+ * be initialized from here.
  */
 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);
This page took 0.026455 seconds and 5 git commands to generate.