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

From: Christian Loehle
Date: Tue Aug 12 2025 - 05:10:32 EST


On 8/12/25 00:38, Tejun Heo wrote:
> 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?

Indeed now that this no longer has to be a drop-in replacement.