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

From: Vincent Guittot

Date: Fri Oct 23 2026 - 08:32:30 EST


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 ...
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

> task_tick_numa(rq, curr);
>
> task_tick_cache(rq, curr);
> --
> 2.52.0
>