Re: [PATCH 2/7] sched: restore preferred CPUs when hotplug removes the last one

From: Yury Norov

Date: Thu Nov 19 2026 - 11:47:13 EST


On Thu, Nov 19, 2026 at 11:43:40AM +0530, Shrikanth Hegde wrote:
> Hi Yury.
>
> On 11/14/26 12:12 AM, Yury Norov wrote:
> > Offlining the last preferred CPU leaves cpu_preferred_mask empty. Normal
> > fair load balancing stops, potentially leaving CPUs idle while having
> > queued tasks.
> >
> > Currently, steal governor is the only module that may modify the mask,
> > so it takes care of it by resetting the mask to mirror the active cpumask.
> >
> > The design allows alternative preferred cpumask managers; relying on
> > loadable modules to maintain consistency of the core data structure
> > is not worthwhile in general.
> >
> > Restore all remaining active CPUs as preferred in sched_cpu_deactivate()
> > path, without relying on the steal governor to recover.
> >
> > Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
> > ---
> > kernel/sched/core.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 175b52a7ea79..b5c158c4efad 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -8723,6 +8723,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);
>
> pr_warn instead?

Warning implies something unexpected or undesirable that might need
user investigation. Notice is something noteworthy but otherwise
normal.

>From the scheduler perspective, this is completely recoverable
situation, and the message is exactly about it. Nothing to warn about.

Thanks,
Yury

> > + reset_preferred_cpumask();
> > + }
> > +#endif
> > +
> > /*
> > * From this point forward, this CPU will refuse to run any task that
> > * is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively