Re: [PATCH sched_ext/for-7.4-fixes] sched_ext: Clarify ops.sub_caps_updated() context and intended use
From: Tejun Heo
Date: Mon Nov 30 2026 - 10:26:41 EST
Hello, Kuba.
On Mon, Nov 30, 2026 at 12:55:09PM +0000, Kuba Piecuch wrote:
> + * Delivered synchronously from the parent's scx_bpf_sub_grant() /
> + * scx_bpf_sub_revoke() after the shard lock is released, or unlocked
> + * from scx_sub_seed_caps() when seeding caps granted during
> + * ops.sub_attach(). It therefore inherits whatever locking context
> + * the parent holds (e.g. an rq lock, or unlocked from an unlocked
> + * caller) and may run before the change takes effect on any given cpu.
AFAICS, this doesn't hold when a delivery for the shard is already in
flight. caps_updated_record() then only folds the change into the buffer
and the kfunc returns without delivering it. The caller which is already
delivering reports the change from its own context, possibly after the
kfunc that made the change has returned. This can only happen when updates
to the same shard race each other. Maybe we can figure out something
better in the future but, for now, can you document the condition? The
same goes for the struct scx_caps_updated comment and the two kfunc
comments.
Also, scx_bpf_sub_revoke() walks the whole subtree, so the caller can be
any ancestor, not only the parent.
> + * Any resulting ops.sub_caps_updated() callbacks are delivered synchronously
> + * after the shard locks are released (inheriting the caller's locking context),
> + * except when called from ops.sub_attach(), where scx_sub_seed_caps() delivers
> + * them unlocked once the child's ops are ready.
Leaving the delivery to scx_sub_seed_caps() isn't specific to
ops.sub_attach(). It happens for any grant or revoke made before the
child's ops are ready.
Thanks.
--
tejun