The lockup detector (watchdog) affinity is initially set based on the
HK_TYPE_TIMER housekeeping mask. However, if this mask is updated at
runtime, the watchdog threads remain on their original CPUs.
Register a housekeeping notifier to update watchdog_cpumask and trigger
a reconfiguration via proc_watchdog_update() when the HK_TYPE_TIMER
housekeeping mask changes. This ensures that watchdog threads are
synchronized with the new isolation boundaries.
Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
Signed-off-by: Qiliang Yuan <yuanql9@chinatelecom.cn>
---
kernel/watchdog.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 366122f4a0f8..2922d7f93d61 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>
@@ -1359,6 +1360,28 @@ 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) {
+ unsigned int type = (unsigned long)data;
+
+ if (type == HK_TYPE_TIMER) {
+ mutex_lock(&watchdog_mutex);
+ cpumask_copy(&watchdog_cpumask,
+ housekeeping_cpumask(HK_TYPE_TIMER));
+ proc_watchdog_update(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())
@@ -1373,4 +1396,5 @@ void __init lockup_detector_init(void)
allow_lockup_detector_init_retry = true;
lockup_detector_setup();
+ housekeeping_register_notifier(&watchdog_housekeeping_nb);
}
--
2.51.0