Re: [RFC PATCHSET sched_ext/for-7.4-fixes] sched_ext: sub: Don't run ops.sub_caps_updated() in an SCX op context
From: Kuba Piecuch
Date: Mon Nov 30 2026 - 07:53:33 EST
Hi Tejun,
On Fri, 27 Nov 2026 15:43, Tejun Heo wrote:
> The synchronous delivery is intentional. Once it's deferred, it becomes
> unclear what happens when there are competing updates.
>
> ops.sub_caps_updated() is there only so that a sub-sched can propagate
> grants and revokes to its own children. It isn't the place for any other
> operation. ops.sub_ecaps_updated() is the one that reports a change once
> it's in effect on the cpu and it runs with the rq locked, so anything
> that acts on the caps, e.g. setting cpuperf, belongs there.
>
> All the listed failure modes are self-inflicted, e.g. a sub-sched calling
> scx_bpf_cidperf_set() from ops.sub_caps_updated() or a parent granting
> from ops.dump*(), and none of them is critical. Isn't this more of a
> documentation problem than anything else?
That makes sense, thanks for clarifying the intent.
The doc comment on @sub_caps_updated in kernel/sched/ext/internal.h
currently says "Delivered asynchronously after the change is recorded",
which is easy to read as running in a separate unlocked context, and
doesn't mention that it may run synchronously in the parent's
grant/revoke context (inheriting whatever lock the parent holds) in
addition to running unlocked.
I'll drop this RFC and send a doc patch clarifying @sub_caps_updated
(may run synchronously in the caller's locking context as well as
unlocked, intended only for tracking caps and propagating
grants/revokes, with cap-acting operations like scx_bpf_cidperf_set()
belonging in ops.sub_ecaps_updated()). Let me know if you'd also want
scx_kfunc_context_filter() to reject rq-lock-sensitive kfuncs from
ops.sub_caps_updated() at load time, or if updating the doc comment is
enough.
Thanks,
Kuba