From: Johannes Weiner <hannes@cmpxchg.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>,
Ingo Molnar <mingo@kernel.org>,
Chengming Zhou <chengming.zhou@linux.dev>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
John Stultz <jstultz@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH resend 2/2] sched: psi: use rq_clock() during task state changes
Date: Tue, 3 Feb 2026 11:34:47 -0500 [thread overview]
Message-ID: <aYIjpyQCkkxxJZ0s@cmpxchg.org> (raw)
In-Reply-To: <20260202204137.GK1395266@noisy.programming.kicks-ass.net>
On Mon, Feb 02, 2026 at 09:41:37PM +0100, Peter Zijlstra wrote:
> On Wed, Jan 14, 2026 at 10:43:17AM -0500, Johannes Weiner wrote:
> > In the hottest psi paths, the scheduler already caches the cpu_clock()
> > call for the event in rq->clock. Now that the clocks between state
> > changes and pressure aggregation don't need to be synchronized inside
> > the seqcount section anymore, use the cheaper rq_clock().
> >
> > Add update_rq_clock() calls to the few places where psi is entered
> > without the rq already locked.
>
> Just to be clear, rq->clock is not a cache of cpu_clock(). rq->clock
> discards all backwards motion (which obviously should never happen, but
> if it does, the clocks go out of sync).
>
> So if you use rq->clock, you must use it for all and not mix with
> cpu_clock().
>
> I *think* the patch does that, but I've not double checked.
Ah no, it does mix them :(
Yeah I'm using rq_clock() consistently on the scheduler side to
accumulate the times of concluded states.
state_start = rq_clock()
...
state_time = rq_clock() - state_start
However, the aggregator side still uses
state_time += cpu_clock() - state_start
to incorporate currently active state. If they don't have the same
base, this won't work.
Doing the full lock and update_rq_clock() from the aggregator sounds
quite heavy handed. How about using sched_clock_cpu() directly and
doing the backwards motion check by hand?
local_irq_save()
now = sched_clock_cpu(cpu)
local_irq_restore()
...
if (state_mask & (1 << s) && now > state_start)
times[s] += now - state_start
next prev parent reply other threads:[~2026-02-03 16:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 15:43 [PATCH resend 1/2] sched: psi: loosen clock sync between scheduler and aggregator Johannes Weiner
2026-01-14 15:43 ` [PATCH resend 2/2] sched: psi: use rq_clock() during task state changes Johannes Weiner
2026-02-02 20:41 ` Peter Zijlstra
2026-02-03 16:34 ` Johannes Weiner [this message]
2026-01-28 10:35 ` [PATCH resend 1/2] sched: psi: loosen clock sync between scheduler and aggregator Peter Zijlstra
2026-01-28 18:56 ` Johannes Weiner
2026-01-28 20:17 ` Peter Zijlstra
2026-02-03 15:38 ` Johannes Weiner
2026-02-03 21:02 ` Johannes Weiner
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=aYIjpyQCkkxxJZ0s@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=chengming.zhou@linux.dev \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=surenb@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
Powered by JetHome