diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-10-02 06:34:50 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-10-04 04:53:53 -0400 |
commit | 6b9dc4806b28214a4a260517e59439e0ac12a15e (patch) | |
tree | 7d233652a05a29c420e274ee00727be7a079ebb8 | |
parent | 77c01d11bbb2b5c005347061bf543ab94878314c (diff) |
watchdog/core, powerpc: Replace watchdog_nmi_reconfigure()
The recent cleanup of the watchdog code split watchdog_nmi_reconfigure()
into two stages. One to stop the NMI and one to restart it after
reconfiguration. That was done by adding a boolean 'run' argument to the
code, which is functionally correct but not necessarily a piece of art.
Replace it by two explicit functions: watchdog_nmi_stop() and
watchdog_nmi_start().
Fixes: 6592ad2fcc8f ("watchdog/core, powerpc: Make watchdog_nmi_reconfigure() two stage")
Requested-by: Linus 'Nursing his pet-peeve' Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: Thomas 'Mopping up garbage' 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.1710021957480.2114@nanos
-rw-r--r-- | arch/powerpc/kernel/watchdog.c | 23 | ||||
-rw-r--r-- | include/linux/nmi.h | 3 | ||||
-rw-r--r-- | kernel/watchdog.c | 33 |
3 files changed, 34 insertions, 25 deletions
diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index dfb067764480..2673ec8bec00 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c | |||
@@ -355,19 +355,24 @@ static void watchdog_calc_timeouts(void) | |||
355 | wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5; | 355 | wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5; |
356 | } | 356 | } |
357 | 357 | ||
358 | void watchdog_nmi_reconfigure(bool run) | 358 | void watchdog_nmi_stop(void) |
359 | { | 359 | { |
360 | int cpu; | 360 | int cpu; |
361 | 361 | ||
362 | cpus_read_lock(); | 362 | cpus_read_lock(); |
363 | if (!run) { | 363 | for_each_cpu(cpu, &wd_cpus_enabled) |
364 | for_each_cpu(cpu, &wd_cpus_enabled) | 364 | stop_wd_on_cpu(cpu); |
365 | stop_wd_on_cpu(cpu); | 365 | cpus_read_unlock(); |
366 | } else { | 366 | } |
367 | watchdog_calc_timeouts(); | 367 | |
368 | for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask) | 368 | void watchdog_nmi_start(void) |
369 | start_wd_on_cpu(cpu); | 369 | { |
370 | } | 370 | int cpu; |
371 | |||
372 | cpus_read_lock(); | ||
373 | watchdog_calc_timeouts(); | ||
374 | for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask) | ||
375 | start_wd_on_cpu(cpu); | ||
371 | cpus_read_unlock(); | 376 | cpus_read_unlock(); |
372 | } | 377 | } |
373 | 378 | ||
diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 89ba8b23c6fe..0c9ed49fb21a 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h | |||
@@ -109,7 +109,8 @@ static inline int hardlockup_detector_perf_init(void) { return 0; } | |||
109 | # endif | 109 | # endif |
110 | #endif | 110 | #endif |
111 | 111 | ||
112 | void watchdog_nmi_reconfigure(bool run); | 112 | void watchdog_nmi_stop(void); |
113 | void watchdog_nmi_start(void); | ||
113 | 114 | ||
114 | /** | 115 | /** |
115 | * touch_nmi_watchdog - restart NMI watchdog timeout. | 116 | * touch_nmi_watchdog - restart NMI watchdog timeout. |
diff --git a/kernel/watchdog.c b/kernel/watchdog.c index f6ef163b72cd..6ad6226535d0 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c | |||
@@ -123,24 +123,27 @@ int __weak __init watchdog_nmi_probe(void) | |||
123 | } | 123 | } |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * watchdog_nmi_reconfigure - Optional function to reconfigure NMI watchdogs | 126 | * watchdog_nmi_stop - Stop the watchdog for reconfiguration |
127 | * @run: If false stop the watchdogs on all enabled CPUs | ||
128 | * If true start the watchdogs on all enabled CPUs | ||
129 | * | 127 | * |
130 | * The core call order is: | 128 | * The reconfiguration steps are: |
131 | * watchdog_nmi_reconfigure(false); | 129 | * watchdog_nmi_stop(); |
132 | * update_variables(); | 130 | * update_variables(); |
133 | * watchdog_nmi_reconfigure(true); | 131 | * watchdog_nmi_start(); |
132 | */ | ||
133 | void __weak watchdog_nmi_stop(void) { } | ||
134 | |||
135 | /** | ||
136 | * watchdog_nmi_start - Start the watchdog after reconfiguration | ||
134 | * | 137 | * |
135 | * The second call which starts the watchdogs again guarantees that the | 138 | * Counterpart to watchdog_nmi_stop(). |
136 | * following variables are stable across the call. | 139 | * |
140 | * The following variables have been updated in update_variables() and | ||
141 | * contain the currently valid configuration: | ||
137 | * - watchdog_enabled | 142 | * - watchdog_enabled |
138 | * - watchdog_thresh | 143 | * - watchdog_thresh |
139 | * - watchdog_cpumask | 144 | * - watchdog_cpumask |
140 | * | ||
141 | * After the call the variables can be changed again. | ||
142 | */ | 145 | */ |
143 | void __weak watchdog_nmi_reconfigure(bool run) { } | 146 | void __weak watchdog_nmi_start(void) { } |
144 | 147 | ||
145 | /** | 148 | /** |
146 | * lockup_detector_update_enable - Update the sysctl enable bit | 149 | * lockup_detector_update_enable - Update the sysctl enable bit |
@@ -551,13 +554,13 @@ static void softlockup_unpark_threads(void) | |||
551 | 554 | ||
552 | static void softlockup_reconfigure_threads(void) | 555 | static void softlockup_reconfigure_threads(void) |
553 | { | 556 | { |
554 | watchdog_nmi_reconfigure(false); | 557 | watchdog_nmi_stop(); |
555 | softlockup_park_all_threads(); | 558 | softlockup_park_all_threads(); |
556 | set_sample_period(); | 559 | set_sample_period(); |
557 | lockup_detector_update_enable(); | 560 | lockup_detector_update_enable(); |
558 | if (watchdog_enabled && watchdog_thresh) | 561 | if (watchdog_enabled && watchdog_thresh) |
559 | softlockup_unpark_threads(); | 562 | softlockup_unpark_threads(); |
560 | watchdog_nmi_reconfigure(true); | 563 | watchdog_nmi_start(); |
561 | } | 564 | } |
562 | 565 | ||
563 | /* | 566 | /* |
@@ -602,9 +605,9 @@ static inline void watchdog_disable_all_cpus(void) { } | |||
602 | static inline void softlockup_init_threads(void) { } | 605 | static inline void softlockup_init_threads(void) { } |
603 | static void softlockup_reconfigure_threads(void) | 606 | static void softlockup_reconfigure_threads(void) |
604 | { | 607 | { |
605 | watchdog_nmi_reconfigure(false); | 608 | watchdog_nmi_stop(); |
606 | lockup_detector_update_enable(); | 609 | lockup_detector_update_enable(); |
607 | watchdog_nmi_reconfigure(true); | 610 | watchdog_nmi_start(); |
608 | } | 611 | } |
609 | #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ | 612 | #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ |
610 | 613 | ||