Commit 6b9dc480 authored by Thomas Gleixner's avatar Thomas Gleixner

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: 6592ad2f ("watchdog/core, powerpc: Make watchdog_nmi_reconfigure() two stage")
Requested-by: default avatarLinus 'Nursing his pet-peeve' Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: default avatarThomas 'Mopping up garbage' Gleixner <tglx@linutronix.de>
Acked-by: default avatarMichael 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
parent 77c01d11
...@@ -355,19 +355,24 @@ static void watchdog_calc_timeouts(void) ...@@ -355,19 +355,24 @@ static void watchdog_calc_timeouts(void)
wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5; wd_timer_period_ms = watchdog_thresh * 1000 * 2 / 5;
} }
void watchdog_nmi_reconfigure(bool run) void watchdog_nmi_stop(void)
{ {
int cpu; int cpu;
cpus_read_lock(); cpus_read_lock();
if (!run) { for_each_cpu(cpu, &wd_cpus_enabled)
for_each_cpu(cpu, &wd_cpus_enabled) stop_wd_on_cpu(cpu);
stop_wd_on_cpu(cpu); cpus_read_unlock();
} else { }
watchdog_calc_timeouts();
for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask) void watchdog_nmi_start(void)
start_wd_on_cpu(cpu); {
} int cpu;
cpus_read_lock();
watchdog_calc_timeouts();
for_each_cpu_and(cpu, cpu_online_mask, &watchdog_cpumask)
start_wd_on_cpu(cpu);
cpus_read_unlock(); cpus_read_unlock();
} }
......
...@@ -109,7 +109,8 @@ static inline int hardlockup_detector_perf_init(void) { return 0; } ...@@ -109,7 +109,8 @@ static inline int hardlockup_detector_perf_init(void) { return 0; }
# endif # endif
#endif #endif
void watchdog_nmi_reconfigure(bool run); void watchdog_nmi_stop(void);
void watchdog_nmi_start(void);
/** /**
* touch_nmi_watchdog - restart NMI watchdog timeout. * touch_nmi_watchdog - restart NMI watchdog timeout.
......
...@@ -123,24 +123,27 @@ int __weak __init watchdog_nmi_probe(void) ...@@ -123,24 +123,27 @@ int __weak __init watchdog_nmi_probe(void)
} }
/** /**
* watchdog_nmi_reconfigure - Optional function to reconfigure NMI watchdogs * watchdog_nmi_stop - Stop the watchdog for reconfiguration
* @run: If false stop the watchdogs on all enabled CPUs
* If true start the watchdogs on all enabled CPUs
* *
* The core call order is: * The reconfiguration steps are:
* watchdog_nmi_reconfigure(false); * watchdog_nmi_stop();
* update_variables(); * update_variables();
* watchdog_nmi_reconfigure(true); * watchdog_nmi_start();
*/
void __weak watchdog_nmi_stop(void) { }
/**
* watchdog_nmi_start - Start the watchdog after reconfiguration
* *
* The second call which starts the watchdogs again guarantees that the * Counterpart to watchdog_nmi_stop().
* following variables are stable across the call. *
* The following variables have been updated in update_variables() and
* contain the currently valid configuration:
* - watchdog_enabled * - watchdog_enabled
* - watchdog_thresh * - watchdog_thresh
* - watchdog_cpumask * - watchdog_cpumask
*
* After the call the variables can be changed again.
*/ */
void __weak watchdog_nmi_reconfigure(bool run) { } void __weak watchdog_nmi_start(void) { }
/** /**
* lockup_detector_update_enable - Update the sysctl enable bit * lockup_detector_update_enable - Update the sysctl enable bit
...@@ -551,13 +554,13 @@ static void softlockup_unpark_threads(void) ...@@ -551,13 +554,13 @@ static void softlockup_unpark_threads(void)
static void softlockup_reconfigure_threads(void) static void softlockup_reconfigure_threads(void)
{ {
watchdog_nmi_reconfigure(false); watchdog_nmi_stop();
softlockup_park_all_threads(); softlockup_park_all_threads();
set_sample_period(); set_sample_period();
lockup_detector_update_enable(); lockup_detector_update_enable();
if (watchdog_enabled && watchdog_thresh) if (watchdog_enabled && watchdog_thresh)
softlockup_unpark_threads(); softlockup_unpark_threads();
watchdog_nmi_reconfigure(true); watchdog_nmi_start();
} }
/* /*
...@@ -602,9 +605,9 @@ static inline void watchdog_disable_all_cpus(void) { } ...@@ -602,9 +605,9 @@ static inline void watchdog_disable_all_cpus(void) { }
static inline void softlockup_init_threads(void) { } static inline void softlockup_init_threads(void) { }
static void softlockup_reconfigure_threads(void) static void softlockup_reconfigure_threads(void)
{ {
watchdog_nmi_reconfigure(false); watchdog_nmi_stop();
lockup_detector_update_enable(); lockup_detector_update_enable();
watchdog_nmi_reconfigure(true); watchdog_nmi_start();
} }
#endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment