Re: [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup
From: Tejun Heo
Date: Fri Dec 04 2026 - 12:09:58 EST
Hello, Changwoo.
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?
Thanks.
--
tejun