]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Shift scx_kick_cpu() validity check to scx_bpf_kick_cpu()
authorTejun Heo <tj@kernel.org>
Wed, 29 Apr 2026 18:09:10 +0000 (08:09 -1000)
committerTejun Heo <tj@kernel.org>
Wed, 29 Apr 2026 18:25:07 +0000 (08:25 -1000)
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@kernel.org>
Reviewed-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Reviewed-by: Changwoo Min <changwoo@igalia.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c

index 2f16dc2b814befb821166475ff21e6002b7f72e9..6575b52f4b9d5ffa6eeb758a8c2b02f438773ccd 100644 (file)
@@ -8812,9 +8812,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);
 
        this_rq = this_rq();
@@ -8877,7 +8874,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);
 }