[PATCH v2 06/12] watchdog: Allow runtime toggle of lockup detector affinity

Qiliang Yuan
2026-04-13T07:44:26Z

The hardlockup detector threads are affined to CPUs based on the
HK_TYPE_TIMER housekeeping mask at boot. If this mask is updated at
runtime, these threads remain on their original CPUs, potentially
running on isolated cores.

Synchronize watchdog thread affinity with HK_TYPE_TIMER updates.

This ensures that hardlockup detector threads correctly follow the
dynamic housekeeping boundaries for timers.

Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
---
kernel/watchdog.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 7d675781bc917..bcd8373038126 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -26,6 +26,7 @@
#include <linux/sysctl.h>
#include <linux/tick.h>
#include <linux/sys_info.h>
+#include <linux/sched/isolation.h>

#include <linux/sched/clock.h>
#include <linux/sched/debug.h>
@@ -1361,6 +1362,30 @@ static int __init lockup_detector_check(void)
}
late_initcall_sync(lockup_detector_check);

+static int watchdog_housekeeping_reconfigure(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ if (action == HK_UPDATE_MASK) {
+ struct housekeeping_update *upd = data;
+ unsigned int type = upd->type;
+
+ if (type == HK_TYPE_TIMER) {
+ mutex_lock(&watchdog_mutex);
+ cpumask_copy(&watchdog_cpumask,
+ housekeeping_cpumask(HK_TYPE_TIMER));
+ cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask);
+ __lockup_detector_reconfigure(false);
+ mutex_unlock(&watchdog_mutex);
+ }
+ }
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block watchdog_housekeeping_nb = {
+ .notifier_call = watchdog_housekeeping_reconfigure,
+};
+
void __init lockup_detector_init(void)
{
if (tick_nohz_full_enabled())
@@ -1375,4 +1400,5 @@ void __init lockup_detector_init(void)
allow_lockup_detector_init_retry = true;

lockup_detector_setup();
+ housekeeping_register_notifier(&watchdog_housekeeping_nb);
}

--
2.43.0