Re: [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check

From: Vincent Guittot

Date: Fri Oct 23 2026 - 11:55:44 EST


On Fri, 23 Oct 2026 at 17:21, Gregory Price (Meta) <gourry@xxxxxxxxxx> wrote:
>
> On 2026-10-23 14:23 +0200, Vincent Guittot wrote:
> > On Fri, 23 Oct 2026 at 04:31, Yafang Shao <laoar.shao@xxxxxxxxx> wrote:
> > >
> > > task_tick_fair() checks sched_numa_balancing on every tick. The
> > > static_branch_unlikely() annotation reserves the nop for the disabled case,
> > > so the default configuration (NUMA_BALANCING_DEFAULT_ENABLED=y) pays a
> > > taken jump per tick. Flip the polarity to static_branch_likely() so that
> > > the fast path matches the default.
> > >
> > > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
> > > Acked-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> > > ---
> > > kernel/sched/fair.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > > index 973647ad6c2d..71dc47d6114d 100644
> > > --- a/kernel/sched/fair.c
> > > +++ b/kernel/sched/fair.c
> > > @@ -15351,7 +15351,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
> > > if (queued)
> > > return;
> > >
> > > - if (static_branch_unlikely(&sched_numa_balancing))
> > > + if (static_branch_likely(&sched_numa_balancing))
> >
> > static_branch_unlikely is used by default for other static keys too
> > like sched_cluster_active, sched_cache_active, __sched_core_enabled
> > sched_asym_cpucapacity and others ...
>
> every other instance checking sched_numa_balancing checks likely(), this
> is the odd one out.

Some other places might be behind another key but otherwise it should
be unlikely()

>
> > So systems which don't enable them don't pay a jump when not using it.
> > I don't see why numa should be different
> >
>
> numa balancing ships enabled by default.

Others are also shipped enabled by default

>
> This just looks like cleanup to me.
>
> --
> ~Gregory
>