linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Juri Lelli <juri.lelli@arm.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>
Subject: Re: [PATCH v2 02/10] cpufreq: provide data for frequency-invariant load-tracking support
Date: Thu, 13 Jul 2017 14:18:04 +0530	[thread overview]
Message-ID: <20170713084804.GC352@vireshk-i7> (raw)
In-Reply-To: <14176128.txNmPKaVBr@aspire.rjw.lan>

On 13-07-17, 01:13, Rafael J. Wysocki wrote:
> On Wednesday, July 12, 2017 01:14:26 PM Peter Zijlstra wrote:
> > On Wed, Jul 12, 2017 at 02:57:55PM +0530, Viresh Kumar wrote:

> > > IIUC, it will take more time to change the frequency eventually with
> > > the interrupt-driven state machine as there may be multiple bottom
> > > halves involved here, for supply, clk, etc, which would run at normal
> > > priorities now. And those were boosted currently due to the high
> > > priority sugov thread. And we are fine with that (from performance
> > > point of view) ?
> > 
> > I'm not sure what you mean; bottom halves as in softirq?

Workqueues or normal threads actually. Maybe I am completely wrong,
but this is how I believe things are going to be:

Configuration: Both regulator and clk registers accessible over I2C
bus.

Scheduler calls schedutil, which eventually calls cpufreq driver (w/o
kthread). The cpufreq backend driver will queue a async request with
callback (with regulator core) to update regulator's constraints
(which can sleep as we need to talk over I2C). The callback will be
called once regulator is programmed. And we return right after
submitting the request with regulator core.

Now, I2C transfer will finish (i.e. regulator programmed) and the
driver specific callback will get called. It will try to change the
frequency now and wait (sleep) until it finishes. I hope the regulator
core wouldn't call the driver callback from interrupt context but some
sort of bottom half, maybe workqueue (That's what I was referring to
earlier).

And finally the clk is programmed and the state machine finished.

> > From what I can
> > tell an i2c bus does clk_prepare_enable() on registration and from that
> > point on clk_enable() is usable from atomic contexts.

That assumes that we can access registers of the I2C controller
atomically without sleeping. Not sure how many ARM platforms have I2C
controller connected over a slow bus though.

> > But afaict clk
> > stuff doesn't do interrupts at all.

The clk stuff may not need it if the clock controllers registers can
be accessed atomically. But if (as in my example) the clk controller
is also over the I2C bus, then the interrupt will be provided from I2C
bus and clk routines would return only after transfer is done.

> > (with a note that I absolutely hate the clk locking)

Yeah, that's a beast :)

> > I think the interrupt driven thing can actually be faster than the
> > 'regular' task waiting on the mutex. The regulator message can be
> > locklessly queued (it only ever makes sense to have 1 such message
> > pending, any later one will invalidate a prior one).
> > 
> > Then the i2c interrupt can detect the availability of this pending
> > message and splice it into the transfer queue at an opportune moment.
> > 
> > (of course, the current i2c bits don't support any of that)
> 
> I *guess* the concern is that in the new model there is no control over the
> time of requesting the frequency change and when the change actually
> happens.

Right.

> IIUC the whole point of making the governor thread an RT or DL one is to
> ensure that the change will happen as soon as technically possible, because if
> it doesn't happen in a specific time frame, it can very well be skipped entirely.

Yes, or actually we can have more trouble (below..).

> > > Coming back to where we started from (where should we call
> > > arch_set_freq_scale() from ?).
> > 
> > The drivers.. the core cpufreq doesn't know when (if any) transition is
> > completed.
> 
> Right.
>  
> > > I think we would still need some kind of synchronization between
> > > cpufreq core and the cpufreq drivers to make sure we don't start
> > > another freq change before the previous one is complete. Otherwise
> > > the cpufreq drivers would be required to have similar support with
> > > proper locking in place.
> > 
> > Not sure what you mean; also not sure why. On x86 we never know, cannot
> > know. So why would this stuff be any different.

So as per the above example, the software on ARM requires to program
multiple hardware components (clk, regulator, power-domain, etc) for
changing CPUs frequency. And this has to be non-racy, otherwise we
might have programmed regulator, domain etc, but right before we
change the frequency another request may land which may try to program
the regulator again. We would be screwed badly here.

Its not a problem on X86 because (I believe) most of this is done by
the hardware for you. And you guys don't have to worry for that.

We already take care of these synchronization issues in slow switching
path (cpufreq_freq_transition_begin()), where we guarantee that a new
freq change request doesn't start before the previous one is over.

-- 
viresh

  parent reply	other threads:[~2017-07-13  8:48 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06  9:49 [PATCH v2 00/10] arm, arm64: frequency- and cpu-invariant accounting support for task scheduler Dietmar Eggemann
2017-07-06  9:49 ` [PATCH v2 01/10] drivers base/arch_topology: free cpumask cpus_to_visit Dietmar Eggemann
2017-07-06 10:22   ` Viresh Kumar
2017-07-06 10:59     ` Juri Lelli
2017-07-06 11:15       ` Viresh Kumar
2017-07-07 15:50         ` Dietmar Eggemann
2017-07-06  9:49 ` [PATCH v2 02/10] cpufreq: provide data for frequency-invariant load-tracking support Dietmar Eggemann
2017-07-06 10:40   ` Viresh Kumar
2017-07-06 22:38     ` Rafael J. Wysocki
2017-07-07 16:01     ` Dietmar Eggemann
2017-07-07 16:18       ` Rafael J. Wysocki
2017-07-07 17:06         ` Dietmar Eggemann
2017-07-08 12:09           ` Rafael J. Wysocki
2017-07-10  6:54             ` Viresh Kumar
2017-07-10 12:46               ` Rafael J. Wysocki
2017-07-11  6:39                 ` Viresh Kumar
2017-07-11 15:21                   ` Dietmar Eggemann
2017-07-13 12:40                     ` Sudeep Holla
2017-07-13 13:08                       ` Dietmar Eggemann
2017-07-13 14:06                         ` Sudeep Holla
2017-07-10  9:30             ` Peter Zijlstra
2017-07-10  9:42               ` Viresh Kumar
2017-07-10 10:31                 ` Dietmar Eggemann
2017-07-10 12:02             ` Dietmar Eggemann
2017-07-11  6:01               ` Viresh Kumar
2017-07-11 15:06                 ` Dietmar Eggemann
2017-07-11 14:59                   ` Rafael J. Wysocki
2017-07-11 15:12                     ` Dietmar Eggemann
2017-07-12  4:09                   ` Viresh Kumar
2017-07-12  8:31                     ` Peter Zijlstra
2017-07-12  9:27                       ` Viresh Kumar
2017-07-12 11:14                         ` Peter Zijlstra
2017-07-12 23:13                           ` Rafael J. Wysocki
2017-07-13  7:49                             ` Peter Zijlstra
2017-07-13  8:48                             ` Viresh Kumar [this message]
2017-07-13 11:15                               ` Peter Zijlstra
2017-07-13 14:04                           ` Sudeep Holla
2017-07-13 14:42                             ` Peter Zijlstra
2017-07-13 15:00                               ` Sudeep Holla
2017-07-13 12:54                         ` Sudeep Holla
2017-07-13 12:49                     ` Sudeep Holla
2017-07-10  6:40       ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 03/10] drivers base/arch_topology: " Dietmar Eggemann
2017-07-06 10:45   ` Viresh Kumar
2017-07-07 16:51     ` Dietmar Eggemann
2017-07-06  9:49 ` [PATCH v2 04/10] arm: wire cpufreq input data for frequency-invariant accounting up to the arch Dietmar Eggemann
2017-07-06 10:42   ` Viresh Kumar
2017-07-10 15:13     ` Dietmar Eggemann
2017-07-11  6:32       ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 05/10] arm: wire frequency-invariant accounting support up to the task scheduler Dietmar Eggemann
2017-07-06 10:46   ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 06/10] arm: wire cpu-invariant " Dietmar Eggemann
2017-07-06 10:47   ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 07/10] arm64: wire cpufreq input data for frequency-invariant accounting up to the arch Dietmar Eggemann
2017-07-06 10:48   ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 08/10] arm64: wire frequency-invariant accounting support up to the task scheduler Dietmar Eggemann
2017-07-06 10:48   ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 09/10] arm64: wire cpu-invariant " Dietmar Eggemann
2017-07-06 10:49   ` Viresh Kumar
2017-07-06  9:49 ` [PATCH v2 10/10] drivers base/arch_topology: inline cpu- and frequency-invariant accounting Dietmar Eggemann
2017-07-06 10:57   ` Viresh Kumar
2017-07-10 15:17     ` Dietmar Eggemann

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=20170713084804.GC352@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=catalin.marinas@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=juri.lelli@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vincent.guittot@linaro.org \
    --cc=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).