aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2017-10-03 10:37:53 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-10-04 04:53:54 -0400
commite31d6883f21c1cdfe5bc64e28411f8a92b783fde (patch)
treeb027de413e024bea4f8e88d364b7413bc20ac9b3 /kernel
parent6b9dc4806b28214a4a260517e59439e0ac12a15e (diff)
watchdog/core, powerpc: Lock cpus across reconfiguration
Instead of dropping the cpu hotplug lock after stopping NMI watchdog and threads and reaquiring for restart, the code and the protection rules become more obvious when holding cpu hotplug lock across the full reconfiguration. Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Michael Ellerman <mpe@ellerman.id.au> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Don Zickus <dzickus@redhat.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1710022105570.2114@nanos
Diffstat (limited to 'kernel')
-rw-r--r--kernel/smpboot.c3
-rw-r--r--kernel/watchdog.c10
2 files changed, 10 insertions, 3 deletions
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index ed7507b69b48..5043e7433f4b 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -351,7 +351,7 @@ void smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread
351 static struct cpumask tmp; 351 static struct cpumask tmp;
352 unsigned int cpu; 352 unsigned int cpu;
353 353
354 get_online_cpus(); 354 lockdep_assert_cpus_held();
355 mutex_lock(&smpboot_threads_lock); 355 mutex_lock(&smpboot_threads_lock);
356 356
357 /* Park threads that were exclusively enabled on the old mask. */ 357 /* Park threads that were exclusively enabled on the old mask. */
@@ -367,7 +367,6 @@ void smpboot_update_cpumask_percpu_thread(struct smp_hotplug_thread *plug_thread
367 cpumask_copy(old, new); 367 cpumask_copy(old, new);
368 368
369 mutex_unlock(&smpboot_threads_lock); 369 mutex_unlock(&smpboot_threads_lock);
370 put_online_cpus();
371} 370}
372 371
373static DEFINE_PER_CPU(atomic_t, cpu_hotplug_state) = ATOMIC_INIT(CPU_POST_DEAD); 372static DEFINE_PER_CPU(atomic_t, cpu_hotplug_state) = ATOMIC_INIT(CPU_POST_DEAD);
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 6ad6226535d0..fff90fe10007 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -535,7 +535,6 @@ static void softlockup_update_smpboot_threads(void)
535 535
536 smpboot_update_cpumask_percpu_thread(&watchdog_threads, 536 smpboot_update_cpumask_percpu_thread(&watchdog_threads,
537 &watchdog_allowed_mask); 537 &watchdog_allowed_mask);
538 __lockup_detector_cleanup();
539} 538}
540 539
541/* Temporarily park all watchdog threads */ 540/* Temporarily park all watchdog threads */
@@ -554,6 +553,7 @@ static void softlockup_unpark_threads(void)
554 553
555static void softlockup_reconfigure_threads(void) 554static void softlockup_reconfigure_threads(void)
556{ 555{
556 cpus_read_lock();
557 watchdog_nmi_stop(); 557 watchdog_nmi_stop();
558 softlockup_park_all_threads(); 558 softlockup_park_all_threads();
559 set_sample_period(); 559 set_sample_period();
@@ -561,6 +561,12 @@ static void softlockup_reconfigure_threads(void)
561 if (watchdog_enabled && watchdog_thresh) 561 if (watchdog_enabled && watchdog_thresh)
562 softlockup_unpark_threads(); 562 softlockup_unpark_threads();
563 watchdog_nmi_start(); 563 watchdog_nmi_start();
564 cpus_read_unlock();
565 /*
566 * Must be called outside the cpus locked section to prevent
567 * recursive locking in the perf code.
568 */
569 __lockup_detector_cleanup();
564} 570}
565 571
566/* 572/*
@@ -605,9 +611,11 @@ static inline void watchdog_disable_all_cpus(void) { }
605static inline void softlockup_init_threads(void) { } 611static inline void softlockup_init_threads(void) { }
606static void softlockup_reconfigure_threads(void) 612static void softlockup_reconfigure_threads(void)
607{ 613{
614 cpus_read_lock();
608 watchdog_nmi_stop(); 615 watchdog_nmi_stop();
609 lockup_detector_update_enable(); 616 lockup_detector_update_enable();
610 watchdog_nmi_start(); 617 watchdog_nmi_start();
618 cpus_read_unlock();
611} 619}
612#endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ 620#endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
613 621