]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mm/memcg: Convert to hotplug state machine
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 3 Nov 2016 14:49:59 +0000 (15:49 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 9 Nov 2016 22:45:26 +0000 (23:45 +0100)
Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: linux-mm@kvack.org
Cc: rt@linutronix.de
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: cgroups@vger.kernel.org
Link: http://lkml.kernel.org/r/20161103145021.28528-4-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/cpuhotplug.h
mm/memcontrol.c

index 4174083280d739021da9372c46bbb56682c2f2e1..c622ab349af33ac9423648e3f8ef9a56bb875a3e 100644 (file)
@@ -32,6 +32,7 @@ enum cpuhp_state {
        CPUHP_BLK_MQ_DEAD,
        CPUHP_FS_BUFF_DEAD,
        CPUHP_PRINTK_DEAD,
+       CPUHP_MM_MEMCQ_DEAD,
        CPUHP_WORKQUEUE_PREP,
        CPUHP_POWER_NUMA_PREPARE,
        CPUHP_HRTIMERS_PREPARE,
index 0f870ba43942e74d1d535a13437e446da5863b1a..6c2043509fb52c2a130c8c98f9edeead52707d37 100644 (file)
@@ -1816,22 +1816,13 @@ static void drain_all_stock(struct mem_cgroup *root_memcg)
        mutex_unlock(&percpu_charge_mutex);
 }
 
-static int memcg_cpu_hotplug_callback(struct notifier_block *nb,
-                                       unsigned long action,
-                                       void *hcpu)
+static int memcg_hotplug_cpu_dead(unsigned int cpu)
 {
-       int cpu = (unsigned long)hcpu;
        struct memcg_stock_pcp *stock;
 
-       if (action == CPU_ONLINE)
-               return NOTIFY_OK;
-
-       if (action != CPU_DEAD && action != CPU_DEAD_FROZEN)
-               return NOTIFY_OK;
-
        stock = &per_cpu(memcg_stock, cpu);
        drain_stock(stock);
-       return NOTIFY_OK;
+       return 0;
 }
 
 static void reclaim_high(struct mem_cgroup *memcg,
@@ -5774,16 +5765,17 @@ __setup("cgroup.memory=", cgroup_memory);
 /*
  * 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.
+ * Some parts like memcg_hotplug_cpu_dead() 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)
 {
        int cpu, node;
 
-       hotcpu_notifier(memcg_cpu_hotplug_callback, 0);
+       cpuhp_setup_state_nocalls(CPUHP_MM_MEMCQ_DEAD, "mm/memctrl:dead", NULL,
+                                 memcg_hotplug_cpu_dead);
 
        for_each_possible_cpu(cpu)
                INIT_WORK(&per_cpu_ptr(&memcg_stock, cpu)->work,