Re: [PATCH 4/7] virt: steal_governor: serialize sampling against CPU hotplug
From: Yury Norov
Date: Thu Nov 19 2026 - 11:51:44 EST
On Thu, Nov 19, 2026 at 11:52:19AM +0530, Shrikanth Hegde wrote:
>
>
> On 11/14/26 12:12 AM, Yury Norov wrote:
> > Steal governor is not safe against a concurrent CPU hotplug operation
> > because it can change active and preferred cpumasks during the governor
> > sampling.
> >
> > To address the race, the governor would take the cpus_write_lock(). But
> > that may be impractical for the loadable module.
> >
> > Instead, implement the following locking policy:
> >
> > - if the code takes cpus_write_lock(), it's enough to write-access
> > the preferred cpumask;
> > - if the code takes cpus_read_lock(), it must also take
> > cpu_preferred_mutex in order to modify the preferred mask.
> >
> > The core scheduler and hotplug paths already modify the preferred cpumask
> > under the cpus_write_lock(), so no change in core logic is required.
> >
> > This provides a common update protocol for multiple policy drivers
> > without requiring writers to take the broader CPU hotplug write lock.
> >
>
> This is also necessary if there are multiple writers outside of core hotplug No?
> So should it go with the write interface series?
The race is real, and it's already there, so this is the fix for an
existing functionality.
> > Fixes: 27d47ebce4d6 ("virt/steal_governor: Implement steal_governor policy loop")
> > Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>