From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758787AbcGKMfj (ORCPT ); Mon, 11 Jul 2016 08:35:39 -0400 Received: from www.linutronix.de ([62.245.132.108]:57436 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933936AbcGKMbP (ORCPT ); Mon, 11 Jul 2016 08:31:15 -0400 Message-Id: <20160711122535.775201614@linutronix.de> User-Agent: quilt/0.63-1 Date: Mon, 11 Jul 2016 12:29:05 -0000 From: Anna-Maria Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Richard Cochran , Sebastian Andrzej Siewior , Anna-Maria Gleixner Subject: [patch 61/66] timers: Convert to hotplug state machine References: <20160711122450.923603742@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=0064-timers-Convert-to-hotplug-state-machine.patch X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Richard Cochran 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 Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Anna-Maria Gleixner --- include/linux/cpuhotplug.h | 1 + include/linux/timer.h | 6 ++++++ kernel/cpu.c | 5 +++++ kernel/time/timer.c | 25 ++----------------------- 4 files changed, 14 insertions(+), 23 deletions(-) --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -18,6 +18,7 @@ enum cpuhp_state { CPUHP_RCUTREE_PREP, CPUHP_POWER_NUMA_PREPARE, CPUHP_HRTIMERS_PREPARE, + CPUHP_TIMERS_DEAD, CPUHP_NOTIFY_PREPARE, CPUHP_BRINGUP_CPU, CPUHP_AP_IDLE_DEAD, --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -259,4 +259,10 @@ unsigned long __round_jiffies_up_relativ 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 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -1194,6 +1194,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. --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1577,7 +1577,7 @@ static void migrate_timer_list(struct tv } } -static void migrate_timers(int cpu) +int timers_dead_cpu(unsigned int cpu) { struct tvec_base *old_base; struct tvec_base *new_base; @@ -1610,29 +1610,9 @@ static void migrate_timers(int cpu) spin_unlock(&old_base->lock); spin_unlock_irq(&new_base->lock); put_cpu_ptr(&tvec_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) @@ -1658,7 +1638,6 @@ void __init init_timers(void) { init_timer_cpus(); init_timer_stats(); - timer_register_cpu_notifier(); open_softirq(TIMER_SOFTIRQ, run_timer_softirq); }