Re: [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup
From: Changwoo Min
Date: Sun Dec 06 2026 - 00:38:37 EST
On 12/5/26 2:09 AM, Tejun Heo wrote:
Hello, Changwoo.Yes, v3 does that. From an op called for @p, it relies on the rq lock or
On Thu, Dec 03, 2026 at 01:56:15PM +0900, Changwoo Min wrote:
+ * From @p's own ops, ops.enable() included, @p can't leave the scheduler
+ * concurrently. Elsewhere, e.g. from a timer or a tracing program, the write
+ * can race @p leaving and outlive the clear, as with
+ * scx_bpf_task_set_dsq_vtime(). Synchronizing such writes is the BPF
+ * scheduler's responsibility.
This seems problematic with sub-scheds. AFAICS, a write which races @p
moving to another scheduler can land after the clear and leave the value on
a task that the other scheduler now owns. The other scheduler would then
take it for its own value, so e.g. a sub-sched can make its parent fail.
We have kfuncs which can be called with or without the rq lock held and
grab it as needed, e.g. scx_bpf_cpuperf_set(). Can scx_bpf_task_set_priv()
follow the same style?
pi_lock the op holds. With no lock held, it takes @p's locks. It fails
from any other op, and tracing programs can't call it. The ownership is
checked under those locks, so a write can't land after the clear.
For lockless readers, the store is ordered after the stores that set up
what the value points to, with smp_wmb() and WRITE_ONCE().
Thanks!
Changwoo