* [PATCH 0/2] sched: small changes
@ 2026-10-23 2:31 Yafang Shao
2026-10-23 2:31 ` [PATCH 1/2] sched: fix stale get_pref_llc() stub for !CONFIG_SCHED_CACHE Yafang Shao
2026-10-23 2:31 ` [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check Yafang Shao
0 siblings, 2 replies; 6+ messages in thread
From: Yafang Shao @ 2026-10-23 2:31 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, gourry,
david, tim.c.chen, yu.c.chen
Cc: linux-kernel, Yafang Shao
These improments are found in the implementation of BPF-NUMAB series[0].
They can be applied seperately.
[0]. https://lwn.net/Articles/1101442/
Yafang Shao (2):
sched: fix stale get_pref_llc() stub for !CONFIG_SCHED_CACHE
sched: use static_branch_likely() for the NUMA balancing tick check
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] sched: fix stale get_pref_llc() stub for !CONFIG_SCHED_CACHE
2026-10-23 2:31 [PATCH 0/2] sched: small changes Yafang Shao
@ 2026-10-23 2:31 ` Yafang Shao
2026-10-23 2:31 ` [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check Yafang Shao
1 sibling, 0 replies; 6+ messages in thread
From: Yafang Shao @ 2026-10-23 2:31 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, gourry,
david, tim.c.chen, yu.c.chen
Cc: linux-kernel, Yafang Shao, stable
Commit b636fef85bda ("sched/cache: Introduce task_struct->sched_cache_grp
to fix UAF") switched get_pref_llc() from taking a struct mm_struct * to
taking the task's struct sched_cache_group *, but only updated the
CONFIG_SCHED_CACHE definition and its caller: the stub in the
!CONFIG_SCHED_CACHE branch kept the old mm_struct parameter.
Fixes: b636fef85bda ("sched/cache: Introduce task_struct->sched_cache_grp to fix UAF")
Cc: <stable@vger.kernel.org> #v7.2.x
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Chen Yu <yu.c.chen@intel.com>
Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
---
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 57360f5cdde4..973647ad6c2d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2194,7 +2194,7 @@ void init_sched_mm(struct task_struct *p) { }
static void task_tick_cache(struct rq *rq, struct task_struct *p) { }
static inline int get_pref_llc(struct task_struct *p,
- struct mm_struct *mm)
+ struct sched_cache_group *grp)
{
return -1;
}
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check
2026-10-23 2:31 [PATCH 0/2] sched: small changes Yafang Shao
2026-10-23 2:31 ` [PATCH 1/2] sched: fix stale get_pref_llc() stub for !CONFIG_SCHED_CACHE Yafang Shao
@ 2026-10-23 2:31 ` Yafang Shao
2026-10-23 12:23 ` Vincent Guittot
1 sibling, 1 reply; 6+ messages in thread
From: Yafang Shao @ 2026-10-23 2:31 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, gourry,
david, tim.c.chen, yu.c.chen
Cc: linux-kernel, Yafang Shao
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@gmail.com>
Acked-by: Gregory Price (Meta) <gourry@gourry.net>
---
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))
task_tick_numa(rq, curr);
task_tick_cache(rq, curr);
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check
2026-10-23 2:31 ` [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check Yafang Shao
@ 2026-10-23 12:23 ` Vincent Guittot
2026-10-23 15:21 ` Gregory Price (Meta)
0 siblings, 1 reply; 6+ messages in thread
From: Vincent Guittot @ 2026-10-23 12:23 UTC (permalink / raw)
To: Yafang Shao
Cc: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
mgorman, vschneid, kprateek.nayak, gourry, david, tim.c.chen,
yu.c.chen, linux-kernel
On Fri, 23 Oct 2026 at 04:31, Yafang Shao <laoar.shao@gmail.com> 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@gmail.com>
> Acked-by: Gregory Price (Meta) <gourry@gourry.net>
> ---
> 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check
2026-10-23 12:23 ` Vincent Guittot
@ 2026-10-23 15:21 ` Gregory Price (Meta)
2026-10-23 15:49 ` Vincent Guittot
0 siblings, 1 reply; 6+ messages in thread
From: Gregory Price (Meta) @ 2026-10-23 15:21 UTC (permalink / raw)
To: Vincent Guittot
Cc: Yafang Shao, mingo, peterz, juri.lelli, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, gourry,
david, tim.c.chen, yu.c.chen, linux-kernel
On 2026-10-23 14:23 +0200, Vincent Guittot wrote:
> On Fri, 23 Oct 2026 at 04:31, Yafang Shao <laoar.shao@gmail.com> 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@gmail.com>
> > Acked-by: Gregory Price (Meta) <gourry@gourry.net>
> > ---
> > 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.
> 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.
This just looks like cleanup to me.
--
~Gregory
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check
2026-10-23 15:21 ` Gregory Price (Meta)
@ 2026-10-23 15:49 ` Vincent Guittot
0 siblings, 0 replies; 6+ messages in thread
From: Vincent Guittot @ 2026-10-23 15:49 UTC (permalink / raw)
To: Gregory Price (Meta)
Cc: Yafang Shao, mingo, peterz, juri.lelli, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, david,
tim.c.chen, yu.c.chen, linux-kernel
On Fri, 23 Oct 2026 at 17:21, Gregory Price (Meta) <gourry@gourry.net> wrote:
>
> On 2026-10-23 14:23 +0200, Vincent Guittot wrote:
> > On Fri, 23 Oct 2026 at 04:31, Yafang Shao <laoar.shao@gmail.com> 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@gmail.com>
> > > Acked-by: Gregory Price (Meta) <gourry@gourry.net>
> > > ---
> > > 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
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-23 15:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 2:31 [PATCH 0/2] sched: small changes Yafang Shao
2026-10-23 2:31 ` [PATCH 1/2] sched: fix stale get_pref_llc() stub for !CONFIG_SCHED_CACHE Yafang Shao
2026-10-23 2:31 ` [PATCH 2/2] sched: use static_branch_likely() for the NUMA balancing tick check Yafang Shao
2026-10-23 12:23 ` Vincent Guittot
2026-10-23 15:21 ` Gregory Price (Meta)
2026-10-23 15:49 ` Vincent Guittot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®