]> www.infradead.org Git - users/jedix/linux-maple.git/commit
watchdog/perf: properly initialize the turbo mode timestamp and rearm counter
authorThomas Gleixner <tglx@linutronix.de>
Thu, 11 Jul 2024 20:25:21 +0000 (22:25 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 18 Jul 2024 04:11:34 +0000 (21:11 -0700)
commitf944ffcbc2e1c759764850261670586ddf3bdabb
tree02e4c2e9c602bb76d4bf7d21693fa0116276c57c
parent0fe2356434e157b3952ff4dbdfe0a96070ddcaa2
watchdog/perf: properly initialize the turbo mode timestamp and rearm counter

For systems on which the performance counter can expire early due to turbo
modes the watchdog handler has a safety net in place which validates that
since the last watchdog event there has at least 4/5th of the watchdog
period elapsed.

This works reliably only after the first watchdog event because the per
CPU variable which holds the timestamp of the last event is never
initialized.

So a first spurious event will validate against a timestamp of 0 which
results in a delta which is likely to be way over the 4/5 threshold of the
period.  As this might happen before the first watchdog hrtimer event
increments the watchdog counter, this can lead to false positives.

Fix this by initializing the timestamp before enabling the hardware event.
Reset the rearm counter as well, as that might be non zero after the
watchdog was disabled and reenabled.

Link: https://lkml.kernel.org/r/87frsfu15a.ffs@tglx
Fixes: 7edaeb6841df ("kernel/watchdog: Prevent false positives with turbo modes")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/watchdog_perf.c