Re: [PATCH 5/7] virt: steal_governor: warn on unexpected preferred mask states
From: Shrikanth Hegde
Date: Fri Nov 27 2026 - 23:43:28 EST
Hi Yury.
On 11/14/26 12:12 AM, Yury Norov wrote:
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
paths 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 | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/virt/steal_governor.c b/drivers/virt/steal_governor.c
index 8cd5c0f3e3ef..c34d91267ec1 100644
--- a/drivers/virt/steal_governor.c
+++ b/drivers/virt/steal_governor.c
@@ -142,6 +142,11 @@ static void decrease_preferred_cpus(void)
lockdep_assert_cpus_held();
lockdep_assert_held(&cpu_preferred_mutex);
+
+ /* We can't end up with no preferred CPUs under normal conditions. */
+ if (WARN_ON(cpumask_empty(cpu_preferred_mask)))
+ return;
+
With this, we will end up with 2 WARN's for the same thing.
Once here and once again in preferred_cpus_valid.
What we have in preferred_cpus_valid covers this already. Why again here?
cpu = cpumask_first_and(housekeeping_cpumask(HK_TYPE_KERNEL_NOISE),
cpu_preferred_mask);
if (cpu >= nr_cpu_ids)
@@ -150,8 +155,6 @@ 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)
- return;
/* Find the last CPU which doesn't belong to that first hk_core. */
if (!cpumask_test_cpu(cpu, first_hk_core)) {
@@ -246,7 +249,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;
}
Regarding this series, IMHO we should split the patches into
1.ones which are actually about fixing the hotplug race (PATCH 3 and 6)
2.ones which are needed only when the another write interface comes in (PATCH 1,2,4,5,7).