From: Peter Zijlstra <peterz@infradead.org>
To: Qais Yousef <qyousef@layalina.io>
Cc: Ingo Molnar <mingo@kernel.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Christian Loehle <christian.loehle@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
John Stultz <jstultz@google.com>,
linux-kernel@vger.kernel.org, Wei Wang <wvw@google.com>
Subject: Re: [PATCH v2] sched/uclamp: Fix race condition leading to imbalanced uclamp_rq
Date: Mon, 26 Oct 2026 12:59:00 +0100 [thread overview]
Message-ID: <20261026115900.GG2668200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <9054450c-f85f-402a-a2ff-fa5f314f92c5@layalina.io>
On Mon, Oct 26, 2026 at 11:24:31AM +0000, Qais Yousef wrote:
> On 10/26/26 10:12, Peter Zijlstra wrote:
>
> > > +static inline bool __uclamp_is_imbalanced(struct rq *rq, enum uclamp_id clamp_id)
> > > +{
> > > + struct uclamp_bucket *bucket = rq->uclamp[clamp_id].bucket;
> > > + int bucket_id = UCLAMP_BUCKETS - 1;
> > > +
> > > + /*
> > > + * On idle all bucket.tasks must be 0, or we have hit imbalance
> > > + * problem.
> > > + */
> > > + for ( ; bucket_id >= 0; bucket_id--)
> > > + if (bucket[bucket_id].tasks)
> > > + return true;
> > > +
> > > + return false;
> > > +}
> > > +
> > > +static inline bool uclamp_is_imbalanced(struct rq *rq)
> > > +{
> > > + enum uclamp_id clamp_id;
> > > +
> > > + for_each_clamp_id(clamp_id)
> > > + if(__uclamp_is_imbalanced(rq, clamp_id))
> > > + return true;
> > > +
> > > + return false;
> > > +}
> >
> > Anyway; I was thinking, since we have a hole in struct uclamp_rq; and
> > also uclamp_flags. Can we fold uclamp_flags into the hold, and also use
> > UCLAMP_FLAG_IDLE to detect if we need this bucket scan at all?
>
> Actually maybe we can just check if the flag is not set then this means we
> have a corruption without scanning the buckets. I didn't like the scan, but
> seemed safer for a backport. Let me try that and update.
>
> I can fold the uclamp_flags into buckets, I don't think this will grow and I
> do have a path to help us get rid off uclamp_rq (hopefully) in the future.
>
> Okay to do this as a separate follow up patch? Since this will go to LTS, I
> think safer keep it minimalist and do the folding bit in a separate patch.
Sure; I just noticed these separate things while trying to re acquaint
myself with uclamp ;-)
prev parent reply other threads:[~2026-10-26 11:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 16:26 Qais Yousef
2026-10-26 10:12 ` Peter Zijlstra
2026-10-26 11:24 ` Qais Yousef
2026-10-26 11:59 ` Peter Zijlstra [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261026115900.GG2668200@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=wvw@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®