Re: [PATCH 03/16] sched_ext: Shift scx_kick_cpu() validity check to scx_bpf_kick_cpu()

From: Cheng-Yang Chou

Date: Tue Apr 21 2026 - 09:54:05 EST


Hi Tejun,

On Mon, Apr 20, 2026 at 09:19:32PM -1000, Tejun Heo wrote:
> Callers that already know the cpu is valid shouldn't have to pay for a
> redundant check. scx_kick_cpu() is called from the in-kernel balance loop
> break-out path with the current cpu (trivially valid) and from
> scx_bpf_kick_cpu() with a BPF-supplied cpu that does need validation. Move
> the check out of scx_kick_cpu() into scx_bpf_kick_cpu() so the backend is
> reusable by callers that have already validated.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---
> kernel/sched/ext.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 5571f5995dd8..9e802d73f205 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -8673,9 +8673,6 @@ static void scx_kick_cpu(struct scx_sched *sch, s32 cpu, u64 flags)
> struct rq *this_rq;
> unsigned long irq_flags;
>
> - if (!scx_cpu_valid(sch, cpu, NULL))
> - return;
> -
> local_irq_save(irq_flags);

I initially think of removing the guard here would left a gap, but patch
10's scx_bpf_kick_cid covers it, so

Reviewed-by: Cheng-Yang Chou <yphbchou0911@xxxxxxxxx>

>
> this_rq = this_rq();
> @@ -8738,7 +8735,7 @@ __bpf_kfunc void scx_bpf_kick_cpu(s32 cpu, u64 flags, const struct bpf_prog_aux
>
> guard(rcu)();
> sch = scx_prog_sched(aux);
> - if (likely(sch))
> + if (likely(sch) && scx_cpu_valid(sch, cpu, NULL))
> scx_kick_cpu(sch, cpu, flags);
> }
>
> --
> 2.53.0
>
>

--
Cheers,
Cheng-Yang