timers/core: Convert to hotplug state machine
authorRichard Cochran <rcochran@linutronix.de>
Wed, 13 Jul 2016 17:16:59 +0000 (17:16 +0000)
committerIngo Molnar <mingo@kernel.org>
Fri, 15 Jul 2016 08:41:42 +0000 (10:41 +0200)
When tearing down, call timers_dead_cpu() before notify_dead().
There is a hidden dependency between:

 - timers
 - block multiqueue
 - rcutree

If timers_dead_cpu() comes later than blk_mq_queue_reinit_notify()
that latter function causes a RCU stall.

Signed-off-by: Richard Cochran <rcochran@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153337.566790058@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/linux/cpuhotplug.h
include/linux/timer.h
kernel/cpu.c
kernel/time/timer.c

index 04ecc55009ed089587d0e8b2dbda7f5786b1bac9..15d46d2a1d1601d90b2424ba2ce83127c37708e3 100644 (file)
@@ -16,6 +16,7 @@ enum cpuhp_state {
        CPUHP_X86_APB_DEAD,
        CPUHP_WORKQUEUE_PREP,
        CPUHP_HRTIMERS_PREPARE,
+       CPUHP_TIMERS_DEAD,
        CPUHP_NOTIFY_PREPARE,
        CPUHP_BRINGUP_CPU,
        CPUHP_AP_IDLE_DEAD,
index 4419506b564ecc215b9550b9e1bf4ed4ccbe6e29..51d601f192d421c6e3721c6621d7c3e08dc1a54d 100644 (file)
@@ -273,4 +273,10 @@ unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
 unsigned long round_jiffies_up(unsigned long j);
 unsigned long round_jiffies_up_relative(unsigned long j);
 
+#ifdef CONFIG_HOTPLUG_CPU
+int timers_dead_cpu(unsigned int cpu);
+#else
+#define timers_dead_cpu NULL
+#endif
+
 #endif
index 85500e7fe238732e3ff27f84019e6cdf83c918bb..e1017d92d3089cc7891658b23674623ca930bc64 100644 (file)
@@ -1195,6 +1195,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
                .startup = hrtimers_prepare_cpu,
                .teardown = hrtimers_dead_cpu,
        },
+       [CPUHP_TIMERS_DEAD] = {
+               .name = "timers dead",
+               .startup = NULL,
+               .teardown = timers_dead_cpu,
+       },
        /*
         * Preparatory and dead notifiers. Will be replaced once the notifiers
         * are converted to states.
index cb9ab401e2d9cad40d1f1dc41e33d52642a5d6e2..555670a5143c61bed5e7015f4f13849240be37b9 100644 (file)
@@ -1804,7 +1804,7 @@ static void migrate_timer_list(struct timer_base *new_base, struct hlist_head *h
        }
 }
 
-static void migrate_timers(int cpu)
+int timers_dead_cpu(unsigned int cpu)
 {
        struct timer_base *old_base;
        struct timer_base *new_base;
@@ -1831,29 +1831,9 @@ static void migrate_timers(int cpu)
                spin_unlock_irq(&new_base->lock);
                put_cpu_ptr(&timer_bases);
        }
+       return 0;
 }
 
-static int timer_cpu_notify(struct notifier_block *self,
-                               unsigned long action, void *hcpu)
-{
-       switch (action) {
-       case CPU_DEAD:
-       case CPU_DEAD_FROZEN:
-               migrate_timers((long)hcpu);
-               break;
-       default:
-               break;
-       }
-
-       return NOTIFY_OK;
-}
-
-static inline void timer_register_cpu_notifier(void)
-{
-       cpu_notifier(timer_cpu_notify, 0);
-}
-#else
-static inline void timer_register_cpu_notifier(void) { }
 #endif /* CONFIG_HOTPLUG_CPU */
 
 static void __init init_timer_cpu(int cpu)
@@ -1881,7 +1861,6 @@ void __init init_timers(void)
 {
        init_timer_cpus();
        init_timer_stats();
-       timer_register_cpu_notifier();
        open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
 }