Re: [PATCH v4 1/3] sched_ext: Introduce scx_bpf_cpu_rq_locked()

From: Tejun Heo
Date: Mon Aug 11 2025 - 19:38:10 EST


Hello,

On Mon, Aug 11, 2025 at 10:21:48PM +0100, Christian Loehle wrote:
> +/**
> + * scx_bpf_cpu_rq_locked - Fetch the locked rq of a CPU
> + * @cpu: CPU of the rq
> + */
> +__bpf_kfunc struct rq *scx_bpf_cpu_rq_locked(s32 cpu)
> +{
> + struct rq *rq;
> +
> + if (!kf_cpu_valid(cpu, NULL))
> + return NULL;
> +
> + preempt_disable();
> + rq = cpu_rq(cpu);
> + if (rq != scx_locked_rq()) {
> + scx_kf_error("Accessing not locked rq %d", cpu);
> + rq = NULL;
> + }
> + preempt_enable();
> + return rq;
> +}

Do we need @cpu? What do you think about making the function not take any
arguments and just return the locked rq?

Thanks.

--
tejun