[PATCH v6 13/23] virt/steal_monitor: Restore to active on module disable

From: Shrikanth Hegde

Date: Wed Jul 01 2026 - 10:27:24 EST


When the module is not in use, preferred CPUs must be same
as active CPUs.

Even if one disables the module during high steal time, it
still restores the preferred CPUs to be same as active CPUs
to keep disable path simple.

Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
v5->v6:
- Add cpus_read_lock() for hotplug safety

drivers/virt/steal_monitor/sm_core.c | 3 +++
drivers/virt/steal_monitor/sm_core.h | 1 +
2 files changed, 4 insertions(+)

diff --git a/drivers/virt/steal_monitor/sm_core.c b/drivers/virt/steal_monitor/sm_core.c
index e320559c6576..222c23286043 100644
--- a/drivers/virt/steal_monitor/sm_core.c
+++ b/drivers/virt/steal_monitor/sm_core.c
@@ -23,6 +23,9 @@ static int __init steal_monitor_init(void)
static void __exit steal_monitor_exit(void)
{
pr_info("steal_monitor is disabled\n");
+
+ guard(cpus_read_lock)();
+ cpumask_copy(&__cpu_preferred_mask, cpu_active_mask);
}

module_init(steal_monitor_init);
diff --git a/drivers/virt/steal_monitor/sm_core.h b/drivers/virt/steal_monitor/sm_core.h
index 684a258526e1..40913aeccf16 100644
--- a/drivers/virt/steal_monitor/sm_core.h
+++ b/drivers/virt/steal_monitor/sm_core.h
@@ -7,5 +7,6 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/cpuhplock.h>

#endif /* __VIRT_STEAL_CORE_H */
--
2.47.3