Re: [PATCH v2] sched_ext: Reset cpuperf_target when a sub loses SCX_CAP_PERF or dies

From: Tao Cui

Date: Thu Oct 08 2026 - 00:37:45 EST


Hello Tejun,

在 2026/10/7 03:31, Tejun Heo 写道:
> Hello, Tao.
>
> On Tue, Oct 06, 2026 at 10:28:34PM +0800, Tao Cui wrote:
>> Fix it by restoring the neutral base that the root scheduler establishes
>> at enable time, at every point where a writer loses the ability to
>> write:
>
> I don't think the kernel should be picking a value here. The cpuperf target
> is last-writer-wins state with no owner tracking, and the only value the
> kernel ever imposes is the initialization at enable. If a parent grants
> SCX_CAP_PERF to a child, it should expect the child to have changed the
> targets, and restoring them after a revoke or in ops.sub_detach() is the
> parent's responsibility. The root holds every cap and a sub-sched parent
> holds PERF wherever it could grant it, so the rewrite always has the cap.
>
> There is a gap on the kernel side which makes that unreliable right now.
> ops.sub_detach() runs before the child's ops.exit() and before the child
> loses kfunc access, so a child timer or its ops.exit() can still write
> after the parent has cleaned up. I'll post a patch which drops the dying
> child's caps before ops.sub_detach() so that the child is inert by the time
> the parent is notified.
>

Fair points. I conflated "the kernel can see a writer go away" with
"the kernel should fix the value". Treating the cpuperf target as
last-writer-wins with enable-time initialization as the only value the
kernel imposes is a cleaner contract, and whoever granted the cap is
the right owner for restoring targets after a revoke. I'm dropping my
patch.

Thanks.
--
Tao

> Thanks.
>
> --
> tejun