Linux Power Management development
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Christian Loehle <christian.loehle@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	Hongyan Xia <hongyan.xia2@arm.com>,
	John Stultz <jstultz@google.com>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7] sched: Consolidate cpufreq updates
Date: Mon, 2 Sep 2024 14:34:02 +0100	[thread overview]
Message-ID: <20240902133402.dhyhnktol6pqj6jg@airbuntu> (raw)
In-Reply-To: <20240902125815.vu3s25ciib34eu3a@airbuntu>

On 09/02/24 13:58, Qais Yousef wrote:
> On 09/02/24 14:30, Vincent Guittot wrote:
> > On Sun, 1 Sept 2024 at 19:51, Qais Yousef <qyousef@layalina.io> wrote:
> > >
> > > On 08/13/24 10:27, Vincent Guittot wrote:
> > > > On Tue, 13 Aug 2024 at 10:25, Vincent Guittot
> > > > <vincent.guittot@linaro.org> wrote:
> > > > >
> > > > > On Mon, 5 Aug 2024 at 17:35, Christian Loehle <christian.loehle@arm.com> wrote:
> > > > > > Hi Qais,
> > > > > > the idea of SCHED_CPUFREQ_FORCE_UPDATE and the possiblity of spamming
> > > > > > freq updates still bothered me so let me share my thoughts even though
> > > > > > it might be niche enough for us not to care.
> > > > > >
> > > > > > 1. On fast_switch systems, assuming they are fine with handling the
> > > > > > actual updates, we have a bit more work on each context_switch() and
> > > > > > some synchronisation, too. That should be fine, if anything there's
> > > > > > some performance regression in a couple of niche cases.
> > > > > >
> > > > > > 2. On !fast_switch systems this gets more interesting IMO. So we have
> > > > > > a sugov DEADLINE task wakeup for every (in a freq-diff resulting)
> > > > > > update request. This task will preempt whatever and currently will
> > > > > > pretty much always be running on the CPU it ran last on (so first CPU
> > > > > > of the PD).
> > > > >
> > > > > The !fast_switch is a bit of concern for me too but not for the same
> > > > > reason and maybe the opposite of yours IIUC your proposal below:
> > > > >
> > > > > With fast_switch we have the following sequence:
> > > > >
> > > > > sched_switch() to task A
> > > > > cpufreq_driver_fast_switch -> write new freq target
> > > > > run task A
> > > > >
> > > > > This is pretty straight forward but we have the following sequence
> > > > > with !fast_switch
> > > > >
> > > > > sched_switch() to task A
> > > > > queue_irq_work -> raise an IPI on local CPU
> > > > > Handle IPI -> wakeup and queue sugov dl worker on local CPU (always
> > > > > with 1 CPU per PD)
> > > > > sched_switch() to sugov dl task
> > > > > __cpufreq_driver_target() which can possibly block on a lock
> > > > > sched_switch() to task A
> > > > > run task A
> > > > >
> > > >
> > > > sent a bit too early
> > > >
> > > > > We can possibly have 2 context switch and one IPi for each "normal"
> > > > > context switch which is not really optimal
> > > >
> > > > It would be good to find a way to skip the spurious back and forth
> > > > between the normal task and sugov
> > >
> > > Hmm I think we use affinity to keep the sugov running on policy->related_cpus.
> > > Relaxing this will make it less of a problem, but won't eliminate it.
> > 
> > yes, but it's not a problem of relaxing affinity here
> 
> If we have 1 CPU per PD, then relaxing affinity will allow it to run anywhere.
> I am just this will be safe on all platforms of course.
> 
> But yeah, I don't think this is a solution anyway but the simplest thing to
> make it harder to hit.
> 
> > The problem is that the 1st switch to task A will be preempted by
> > sugov so the 1st switch is useless. You should call cpufreq_update
> > before switching to A so that we skip the useless switch to task A and
> > directly switch to sugov 1st then task A
> 
> Can we do this safely after we pick task A, but before we do the actual context
> switch? One of the reasons I put this too late is because there's a late call
> to balance_calbacks() that can impact the state of the rq and important to take
> into account based on my previous testing and analysis.
> 
> Any reason we need to run the sugov worker as DL instead for example being
> a softirq?

I assume it performs non interrupt context safe operations. But I don't think
I've ever seen it sleep during an activation.

  reply	other threads:[~2024-09-02 13:34 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-28 18:45 [PATCH v7] sched: Consolidate cpufreq updates Qais Yousef
2024-07-29 16:01 ` Metin Kaya
2024-08-01 12:22   ` Qais Yousef
2024-08-05 15:35 ` Christian Loehle
2024-08-09  1:13   ` Qais Yousef
2024-08-13  8:25   ` Vincent Guittot
2024-08-13  8:27     ` Vincent Guittot
2024-08-13 16:26       ` Christian Loehle
2024-08-13 16:43         ` Vincent Guittot
2024-08-13 16:56           ` Christian Loehle
2024-09-01 17:51       ` Qais Yousef
2024-09-02 12:30         ` Vincent Guittot
2024-09-02 12:35           ` Christian Loehle
2024-09-02 12:43             ` Vincent Guittot
2024-09-02 12:58           ` Qais Yousef
2024-09-02 13:34             ` Qais Yousef [this message]
2024-09-02 13:40               ` Christian Loehle
2024-09-02 13:36             ` Vincent Guittot
2024-09-02 20:43               ` Qais Yousef
2024-09-03  6:54                 ` Vincent Guittot
2024-08-13 10:02 ` Vincent Guittot
2024-09-01 18:01   ` Qais Yousef
2024-09-03 12:48     ` Vincent Guittot
2024-09-11 20:34 ` Christian Loehle
2024-09-12 11:33   ` Rafael J. Wysocki
2025-02-09 22:34     ` Qais Yousef
2024-10-07 17:20 ` Anjali K
2024-10-08  9:56   ` Christian Loehle
2024-10-10 18:32     ` Christian Loehle
2024-10-18 18:32     ` Anjali K
2024-11-25  6:32       ` Anjali K
2025-02-09 22:33         ` Qais Yousef
2024-10-11  9:34 ` Christian Loehle
2025-02-09 22:41   ` Qais Yousef

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=20240902133402.dhyhnktol6pqj6jg@airbuntu \
    --to=qyousef@layalina.io \
    --cc=bsegall@google.com \
    --cc=christian.loehle@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=hongyan.xia2@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vschneid@redhat.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