Skip to contentSkip to conversation

watchdog: enable watchdog only when watchdog_thresh != 0

PATCH New Puyou Lu 1 participant 1 message Aug 7, 2022

lore
Share & tools
lore

Puyou Lu

author
#0 lore raw

PATCH 1/2 watchdog: enable watchdog only when watchdog_thresh != 0

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

---
 kernel/watchdog.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/watchdog.c +5 -5
index 8e61f21e7e33..bed1fe7ecaea 100644
@@ -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);
Signature · 1 line
2.17.1