[PATCH 5/6] virt: steal_governor: Warn on unexpected preferred mask states

From: Yury Norov

Date: Sun Nov 01 2026 - 14:28:24 EST


Now that preferred cpumask access is properly serialized, and CPU
hotplug restores all remaining active CPUs as preferred when the
last preferred CPU gets offlined, the corresponding logic in the
driver is redundant.

Instead of removing it completely, add WARN_ON()s in the corresponding
conditionals to harden the preferred CPUs mask management and highlight
that this condition is not expected during normal operation.

Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
drivers/virt/steal_governor.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/virt/steal_governor.c b/drivers/virt/steal_governor.c
index bc3936e69eed..5679b7ddc078 100644
--- a/drivers/virt/steal_governor.c
+++ b/drivers/virt/steal_governor.c
@@ -145,7 +145,9 @@ static void decrease_preferred_cpus(void)
/* Always leave first housekeeping core as preferred. */
first_hk_core = topology_sibling_cpumask(cpu);
cpu = cpumask_last(cpu_preferred_mask);
- if (cpu >= nr_cpu_ids)
+
+ /* We can't end up with no preferred CPUs under normal conditions. */
+ if (WARN_ON(cpu >= nr_cpu_ids))
return;

/* Find the last CPU which doesn't belong to that first hk_core. */
@@ -246,7 +248,7 @@ static void steal_governor_loop(struct work_struct *work)
* else: steal ratio is within bounds. Still do design checks so that
* module restores to active if CPU hotplug breaks those assumptions.
*/
- if (!preferred_cpus_valid()) {
+ if (WARN_ON(!preferred_cpus_valid())) {
reset_preferred_cpumask();
return;
}
--
2.53.0