Re: [PATCH v4 1/2] sched/uclamp: Fix race condition leading to imbalanced uclamp_rq

From: Peter Zijlstra

Date: Fri Oct 30 2026 - 08:19:33 EST


On Fri, Oct 30, 2026 at 11:28:25AM +0000, Qais Yousef wrote:

> Peter/Vincent, what do you think? It seems we have a schrodenger task that is
> both enqueued and dequeued simultaneously in these throttling paths. Shouldn't
> this be fixed? If yes, any thoughts on the right approach? Should we throttle
> if there are no other tasks on the rq too? I didn't realize the semantics are
> that strong for enforcing the quota.

Urgh, nothing is ever straight forward is it ...

Bah, so this is because the core does uclamp (for classes that have it
on) but then the class does the throttle without going through the core
{en,de}queue.

Does it make sense to have throttle_Cfs_rq_work() and tg_unthrottle_up()
do uclamp_rq_{dec,inc}() respectively, along with the
{de,en}queue_task_fair() they're already doing?