aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Cochran <rcochran@linutronix.de>2016-07-13 13:16:59 -0400
committerIngo Molnar <mingo@kernel.org>2016-07-15 04:41:42 -0400
commit24f73b99716a9cd8cbb345c41ced6b3b5ed94006 (patch)
tree382df7b88299425d8f3af5b050b7ba26273ea0c5
parent27590dc17b34aedc4f3e14bd107ee59b9db9b0a6 (diff)
timers/core: Convert to hotplug state machine
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>
-rw-r--r--include/linux/cpuhotplug.h1
-rw-r--r--include/linux/timer.h6
-rw-r--r--kernel/cpu.c5
-rw-r--r--kernel/time/timer.c25
4 files changed, 14 insertions, 23 deletions
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 04ecc55009ed..15d46d2a1d16 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -16,6 +16,7 @@ enum cpuhp_state {
16 CPUHP_X86_APB_DEAD, 16 CPUHP_X86_APB_DEAD,
17 CPUHP_WORKQUEUE_PREP, 17 CPUHP_WORKQUEUE_PREP,
18 CPUHP_HRTIMERS_PREPARE, 18 CPUHP_HRTIMERS_PREPARE,
19 CPUHP_TIMERS_DEAD,
19 CPUHP_NOTIFY_PREPARE, 20 CPUHP_NOTIFY_PREPARE,
20 CPUHP_BRINGUP_CPU, 21 CPUHP_BRINGUP_CPU,
21 CPUHP_AP_IDLE_DEAD, 22 CPUHP_AP_IDLE_DEAD,
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 4419506b564e..51d601f192d4 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -273,4 +273,10 @@ unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
273unsigned long round_jiffies_up(unsigned long j); 273unsigned long round_jiffies_up(unsigned long j);
274unsigned long round_jiffies_up_relative(unsigned long j); 274unsigned long round_jiffies_up_relative(unsigned long j);
275 275
276#ifdef CONFIG_HOTPLUG_CPU
277int timers_dead_cpu(unsigned int cpu);
278#else
279#define timers_dead_cpu NULL
280#endif
281
276#endif 282#endif
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 85500e7fe238..e1017d92d308 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1195,6 +1195,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
1195 .startup = hrtimers_prepare_cpu, 1195 .startup = hrtimers_prepare_cpu,
1196 .teardown = hrtimers_dead_cpu, 1196 .teardown = hrtimers_dead_cpu,
1197 }, 1197 },
1198 [CPUHP_TIMERS_DEAD] = {
1199 .name = "timers dead",
1200 .startup = NULL,
1201 .teardown = timers_dead_cpu,
1202 },
1198 /* 1203 /*
1199 * Preparatory and dead notifiers. Will be replaced once the notifiers 1204 * Preparatory and dead notifiers. Will be replaced once the notifiers
1200 * are converted to states. 1205 * are converted to states.
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index cb9ab401e2d9..555670a5143c 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1804,7 +1804,7 @@ static void migrate_timer_list(struct timer_base *new_base, struct hlist_head *h
1804 } 1804 }
1805} 1805}
1806 1806
1807static void migrate_timers(int cpu) 1807int timers_dead_cpu(unsigned int cpu)
1808{ 1808{
1809 struct timer_base *old_base; 1809 struct timer_base *old_base;
1810 struct timer_base *new_base; 1810 struct timer_base *new_base;
@@ -1831,29 +1831,9 @@ static void migrate_timers(int cpu)
1831 spin_unlock_irq(&new_base->lock); 1831 spin_unlock_irq(&new_base->lock);
1832 put_cpu_ptr(&timer_bases); 1832 put_cpu_ptr(&timer_bases);
1833 } 1833 }
1834 return 0;
1834} 1835}
1835 1836
1836static int timer_cpu_notify(struct notifier_block *self,
1837 unsigned long action, void *hcpu)
1838{
1839 switch (action) {
1840 case CPU_DEAD:
1841 case CPU_DEAD_FROZEN:
1842 migrate_timers((long)hcpu);
1843 break;
1844 default:
1845 break;
1846 }
1847
1848 return NOTIFY_OK;
1849}
1850
1851static inline void timer_register_cpu_notifier(void)
1852{
1853 cpu_notifier(timer_cpu_notify, 0);
1854}
1855#else
1856static inline void timer_register_cpu_notifier(void) { }
1857#endif /* CONFIG_HOTPLUG_CPU */ 1837#endif /* CONFIG_HOTPLUG_CPU */
1858 1838
1859static void __init init_timer_cpu(int cpu) 1839static void __init init_timer_cpu(int cpu)
@@ -1881,7 +1861,6 @@ void __init init_timers(void)
1881{ 1861{
1882 init_timer_cpus(); 1862 init_timer_cpus();
1883 init_timer_stats(); 1863 init_timer_stats();
1884 timer_register_cpu_notifier();
1885 open_softirq(TIMER_SOFTIRQ, run_timer_softirq); 1864 open_softirq(TIMER_SOFTIRQ, run_timer_softirq);
1886} 1865}
1887 1866