Re: [PATCH v3 3/3] sched_ext: Guarantee rq lock on scx_bpf_cpu_rq()
From: Tejun Heo
Date: Sat Aug 09 2025 - 15:03:53 EST
Hello,
On Tue, Aug 05, 2025 at 12:10:36PM +0100, Christian Loehle wrote:
> @@ -7420,10 +7420,20 @@ __bpf_kfunc s32 scx_bpf_task_cpu(const struct task_struct *p)
> */
> __bpf_kfunc struct rq *scx_bpf_cpu_rq(s32 cpu)
> {
> + struct rq *rq;
> +
> if (!kf_cpu_valid(cpu, NULL))
> return NULL;
>
> - return cpu_rq(cpu);
> + preempt_disable();
> + rq = cpu_rq(cpu);
> + if (rq != scx_locked_rq()) {
> + scx_kf_error("Accessing not locked rq %d", cpu);
> + rq = NULL;
> + }
> + preempt_enable();
So, this will break the existing scheduler binaries immediately, which I
don't think is a good way to go about it. Can you add a pr_warn_once() to
print deprecation warning and add e.g. scx_bpf_locked_cpu_rq() instead?
Thanks.
--
tejun