[PATCH 1/4] watchdog/hardlockup: Always update saved interrupts during check
From: Mayank Rungta via B4 Relay
Date: Thu Feb 12 2026 - 16:12:38 EST
From: Mayank Rungta <mrungta@xxxxxxxxxx>
Currently, arch_touch_nmi_watchdog() causes an early return that
skips updating hrtimer_interrupts_saved. This leads to stale
comparisons and delayed lockup detection.
Update the saved interrupt count before checking the touched flag
to ensure detection timeliness.
Signed-off-by: Mayank Rungta <mrungta@xxxxxxxxxx>
---
kernel/watchdog.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 7d675781bc917d709aa3fb499629eeac86934f55..b71aa814edcf9ad8f73644eb5bcd1eeb3264e4ed 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -186,7 +186,21 @@ static void watchdog_hardlockup_kick(void)
void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
{
+ bool is_hl;
int hardlockup_all_cpu_backtrace;
+ /*
+ * Check for a hardlockup by making sure the CPU's timer
+ * interrupt is incrementing. The timer interrupt should have
+ * fired multiple times before we overflow'd. If it hasn't
+ * then this is a good indication the cpu is stuck
+ *
+ * Purposely check this _before_ checking watchdog_hardlockup_touched
+ * so we make sure we still update the saved value of the interrupts.
+ * Without that we'll take an extra round through this function before
+ * we can detect a lockup.
+ */
+
+ is_hl = is_hardlockup(cpu);
if (per_cpu(watchdog_hardlockup_touched, cpu)) {
per_cpu(watchdog_hardlockup_touched, cpu) = false;
@@ -195,13 +209,8 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs)
hardlockup_all_cpu_backtrace = (hardlockup_si_mask & SYS_INFO_ALL_BT) ?
1 : sysctl_hardlockup_all_cpu_backtrace;
- /*
- * Check for a hardlockup by making sure the CPU's timer
- * interrupt is incrementing. The timer interrupt should have
- * fired multiple times before we overflow'd. If it hasn't
- * then this is a good indication the cpu is stuck
- */
- if (is_hardlockup(cpu)) {
+
+ if (is_hl) {
unsigned int this_cpu = smp_processor_id();
unsigned long flags;
--
2.53.0.273.g2a3d683680-goog