Re: [PATCH 3/6] sched: Restore preferred CPUs when hotplug removes the last one
From: Yury Norov
Date: Thu Nov 05 2026 - 08:33:56 EST
On Thu, Nov 05, 2026 at 05:05:05PM +0800, Fushuai Wang wrote:
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 04b62c16fa8c..98f4f9434965 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -8712,6 +8712,14 @@ int sched_cpu_deactivate(unsigned int cpu)
> >
> > set_cpu_active(cpu, false);
> >
> > +#ifdef CONFIG_PREFERRED_CPU
> > + if (cpumask_empty(cpu_preferred_mask)) {
> > + pr_notice("sched: last preferred CPU%u offlined; make all active CPUs preferred\n",
> > + cpu);
> > + reset_preferred_cpumask();
>
> Hi, Yury
>
> If the CPU being offlined is the only preferred CPU, after
> reset_preferred_cpumask(), the steal governor may still need
> some time to tighten the mask again, and eventually only one
> preferred CPU may remain. Would this introduce additional
> task migration overhead?
This is the safest fallback from the scheduler POV. Current steal
governor implementation would require multiple iterations to get back
to the old equilibrium. If it will show up as a real problem, we can
teach steal governor to converge faster, and/or detect the preferred
mask reset.
Thanks,
Yury