All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] watchdog: enable watchdog only when watchdog_thresh != 0
@ 2022-08-07 15:17 Puyou Lu
  0 siblings, 0 replies; only message in thread
From: Puyou Lu @ 2022-08-07 15:17 UTC (permalink / raw)
  Cc: Puyou Lu, Petr Mladek, Andrew Morton, Phil Auld,
	Peter Zijlstra (Intel),
	Rasmus Villemoes, John Ogness, Laurent Dufour,
	Frederic Weisbecker, Xiaoming Ni, linux-kernel

We can simplify the check of watchdog_thresh, as watchdog_thresh
shouldn't be zero for both nmi and soft watchdog.

Signed-off-by: Puyou Lu <puyou.lu@gmail.com>
---
 kernel/watchdog.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 8e61f21e7e33..bed1fe7ecaea 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -144,7 +144,7 @@ void __weak watchdog_nmi_start(void) { }
 static void lockup_detector_update_enable(void)
 {
 	watchdog_enabled = 0;
-	if (!watchdog_user_enabled)
+	if (!(watchdog_user_enabled && watchdog_thresh))
 		return;
 	if (nmi_watchdog_available && nmi_watchdog_user_enabled)
 		watchdog_enabled |= NMI_WATCHDOG_ENABLED;
@@ -306,7 +306,7 @@ static int is_softlockup(unsigned long touch_ts,
 			 unsigned long period_ts,
 			 unsigned long now)
 {
-	if ((watchdog_enabled & SOFT_WATCHDOG_ENABLED) && watchdog_thresh){
+	if (watchdog_enabled & SOFT_WATCHDOG_ENABLED) {
 		/* Warn about unreasonable delays. */
 		if (time_after(now, period_ts + get_softlockup_thresh()))
 			return now - touch_ts;
@@ -543,9 +543,10 @@ static void __lockup_detector_reconfigure(void)
 	watchdog_nmi_stop();
 
 	softlockup_stop_all();
+
 	set_sample_period();
 	lockup_detector_update_enable();
-	if (watchdog_enabled && watchdog_thresh)
+	if (watchdog_enabled & SOFT_WATCHDOG_ENABLED)
 		softlockup_start_all();
 
 	watchdog_nmi_start();
@@ -575,8 +576,7 @@ static __init void lockup_detector_setup(void)
 	 */
 	lockup_detector_update_enable();
 
-	if (!IS_ENABLED(CONFIG_SYSCTL) &&
-	    !(watchdog_enabled && watchdog_thresh))
+	if (!IS_ENABLED(CONFIG_SYSCTL) && !watchdog_enabled)
 		return;
 
 	mutex_lock(&watchdog_mutex);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-07 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-07 15:17 [PATCH 1/2] watchdog: enable watchdog only when watchdog_thresh != 0 Puyou Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.