Re: [PATCH 1/2] sched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncs

From: Kuba Piecuch

Date: Tue Nov 24 2026 - 05:29:34 EST


Hi Andrea,

On Tue, 24 Nov 2026 08:00, Andrea Righi wrote:
> Can we express the existing protection in the dereference checks instead
> of adding an RCU lock/unlock pair to every call?
...
> Can we use rcu_dereference_all(dsq->first_task) for the return instead?
>
> That accepts explicit RCU readers and the implicit protection provided
> by disabled preemption, softirqs or interrupts, while retaining the
> pointer-access ordering and lockdep checking.
>
>> @@ -11957,6 +11959,8 @@ __bpf_kfunc struct task_struct *scx_bpf_tid_to_task(u64 tid)
>> {
>> struct sched_ext_entity *scx;
>>
>> + guard(rcu)();
>> +
>> if (!scx_tid_to_task_enabled()) {
>> struct scx_sched *sch = rcu_dereference(scx_root);
>
> Likewise, changing this to rcu_dereference_all(scx_root) should be
> enough.

Agreed, will switch both to rcu_dereference_all() in v2, and convert
scx_bpf_cpu_curr() and scx_bpf_cid_curr() to match.

Thanks,
Kuba