Re: [PATCH] sched: Fix UCLAMP_FLAG_IDLE setting

From: Quentin Perret
Date: Thu Jun 10 2021 - 06:27:55 EST


On Thursday 10 Jun 2021 at 11:00:39 (+0100), Qais Yousef wrote:
> On 06/09/21 14:33, Quentin Perret wrote:
> > The UCLAMP_FLAG_IDLE flag is set on a runqueue when dequeueing the last
> > active task to maintain the last uclamp.max and prevent blocked util
> > from suddenly becoming visible.
> >
> > However, there is an asymmetry in how the flag is set and cleared which
> > can lead to having the flag set whilst there are active task on the rq.
> > Specifically, the flag is set in the uclamp_rq_inc() path, which is
> > called at enqueue time, but cleared in the uclamp_rq_dec_id() which is
>
> It is actually the other way around. It is cleared in uclamp_rq_inc() and
> set in uclamp_rq_dec_id().
>
> > called both when dequeueing and task _and_ during cgroup migrations.
>
> Is it cgroup migrations or when cgroup uclamp values are updated you mean?
>
> It is worth being direct and mention that uclamp_update_active() will perform
> uclamp_rq_dec/inc_id() when the cgroup uclamp values are updated, which would
> end up with the flag set but not cleared in this path.

Yep, that's the problematic path.

> >
> > Fix this by setting the flag in the uclamp_rq_inc_id() path to ensure
> > things remain symmetrical.
> >
> > Reported-by: Rick Yiu <rickyiu@xxxxxxxxxx>
> > Signed-off-by: Quentin Perret <qperret@xxxxxxxxxx>
> > ---
>
> With the commit message fixed.

Ack, this commit message is a mess, I'll rewrite.

> Reviewed-by: Qais Yousef <qais.yousef@xxxxxxx>


Thanks!
Quentin