last_timestamp is not initialized and is zero after boot, or stop to forward when nmi watchdog is disabled; and false positives still is possible when restart NMI timer after stopping 120 seconds
so reassign last_timestamp always when enable nmi event Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes") Signed-off-by: Li RongQing <lirongq...@baidu.com> --- kernel/watchdog_hld.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..fc3a5c7ccd82 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -189,6 +189,8 @@ static int hardlockup_detector_event_create(void) */ void hardlockup_detector_perf_enable(void) { + ktime_t now = ktime_get_mono_fast_ns(); + if (hardlockup_detector_event_create()) return; @@ -196,6 +198,7 @@ void hardlockup_detector_perf_enable(void) if (!atomic_fetch_inc(&watchdog_cpus)) pr_info("Enabled. Permanently consumes one hw-PMU counter.\n"); + this_cpu_write(last_timestamp, now); perf_event_enable(this_cpu_read(watchdog_ev)); } @@ -274,8 +277,12 @@ void __init hardlockup_detector_perf_restart(void) for_each_online_cpu(cpu) { struct perf_event *event = per_cpu(watchdog_ev, cpu); - if (event) + if (event) { + ktime_t now = ktime_get_mono_fast_ns(); + + per_cpu(last_timestamp, cpu) = now; perf_event_enable(event); + } } } -- 2.16.2