2022-08-07 15:40:48

by Puyou Lu

[permalink] [raw]
Subject: [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.

Signed-off-by: Puyou Lu <[email protected]>
---
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