From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Steve Muckle <steve.muckle@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM list <linux-pm@vger.kernel.org>,
Juri Lelli <juri.lelli@arm.com>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Michael Turquette <mturquette@baylibre.com>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH v6 7/7][Resend] cpufreq: schedutil: New governor based on scheduler utilization data
Date: Tue, 29 Mar 2016 14:23:21 +0200 [thread overview]
Message-ID: <1569749.Ubc4LvLySG@vostro.rjw.lan> (raw)
In-Reply-To: <56F97548.1030903@linaro.org>
On Monday, March 28, 2016 11:17:44 AM Steve Muckle wrote:
> On 03/26/2016 06:36 PM, Rafael J. Wysocki wrote:
> >>>> +static int sugov_limits(struct cpufreq_policy *policy)
> >>>> >>> +{
> >>>> >>> + struct sugov_policy *sg_policy = policy->governor_data;
> >>>> >>> +
> >>>> >>> + if (!policy->fast_switch_enabled) {
> >>>> >>> + mutex_lock(&sg_policy->work_lock);
> >>>> >>> +
> >>>> >>> + if (policy->max < policy->cur)
> >>>> >>> + __cpufreq_driver_target(policy, policy->max,
> >>>> >>> + CPUFREQ_RELATION_H);
> >>>> >>> + else if (policy->min > policy->cur)
> >>>> >>> + __cpufreq_driver_target(policy, policy->min,
> >>>> >>> + CPUFREQ_RELATION_L);
> >>>> >>> +
> >>>> >>> + mutex_unlock(&sg_policy->work_lock);
> >>>> >>> + }
> >>> >>
> >>> >> Is the expectation that in the fast_switch_enabled case we should
> >>> >> re-evaluate soon enough that an explicit fixup is not required here?
> >> >
> >> > Yes, it is.
> >> >
> >>> >> I'm worried as to whether that will always be true given the possible
> >>> >> criticality of applying frequency limits (thermal for example).
> >> >
> >> > The part of the patch below that you cut actually takes care of that:
> >> >
> >> > sg_policy->need_freq_update = true;
> >> >
> >> > which causes the rate limit to be ignored essentially, so the
> >> > frequency will be changed on the first update from the scheduler.
>
> The scenario I'm contemplating is that while a CPU-intensive task is
> running a thermal interrupt goes off. The driver for this thermal
> interrupt responds by capping fmax. If this happens just after the tick,
> it seems possible that we could wait a full tick before changing the
> frequency. Given a 10ms tick it could be rather annoying for thermal
> management algorithms on some platforms (I'm familiar with a few).
The thermal driver has to do something like cpufreq_update_policy() then
which can only happen in process context. I'm not sure how it is possible
to guarantee any latency better than that full tick here anyway.
> >> > Which also is why the min/max check is before the sg_policy->next_freq
> >> > == next_freq check in sugov_update_commit().
> >> >
> >> > I wanted to avoid locking in the fast switch/one CPU per policy case
> >> > which otherwise would be necessary just for the handling of this
> >> > thing. I'd like to keep it the way it is unless it can be clearly
> >> > demonstrated that it really would lead to problems in practice in a
> >> > real system.
> >
> > Besides, even if frequency is updated directly from here in the "fast
> > switch" case, that still doesn't guarantee that it will be updated
> > immediately, because the task running this code may be preempted and
> > only scheduled again in the next cycle.
> >
> > Not to mention the fact that it may not run on the CPU to be updated,
> > so it would need to use something like smp_call_function_single() for
> > the update and that would complicate things even more.
> >
> > Overall, I don't really think that doing the update directly from here
> > in the "fast switch" case would improve things much latency-wise and
> > it would increase complexity and introduce overhead into the fast
> > path. So this really is a tradeoff and the current choice is the
> > right one IMO.
>
> On the desire to avoid locking in the fast switch/one CPU per policy
> case, I wondered about whether disabling interrupts in sugov_limits()
> would suffice. That's a rarely called function and I was hoping that the
> update hook would already have interrupts disabled due to its being
> called in scheduler paths that may do raw_spin_lock_irqsave. But I'm not
> sure offhand that will always be true.
It will.
That's why we can use RCU-sched in cpufreq_update_util() etc.
> If it isn't though then I'm not
> sure what's necessarily stopping say the sched tick calling the hook
> while the hook is already in progress from some other path.
>
> Agreed there would need to be some additional complexity somewhere to
> get things running on the correct CPU.
>
> Anyway I have nothing against deferring this for now.
OK
Thanks,
Rafael
next prev parent reply other threads:[~2016-03-29 12:21 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 1:44 [PATCH v6 0/7] cpufreq: schedutil governor Rafael J. Wysocki
2016-03-22 1:46 ` [PATCH v6 1/7][Resend] cpufreq: sched: Helpers to add and remove update_util hooks Rafael J. Wysocki
2016-03-28 5:31 ` Viresh Kumar
2016-03-31 12:47 ` Peter Zijlstra
2016-03-22 1:47 ` [PATCH v6 2/7][Resend] cpufreq: governor: New data type for management part of dbs_data Rafael J. Wysocki
2016-03-22 1:49 ` [PATCH v6 3/7][Resend] cpufreq: governor: Move abstract gov_attr_set code to seperate file Rafael J. Wysocki
2016-03-22 1:50 ` [PATCH v6 4/7][Resend] cpufreq: Move governor attribute set headers to cpufreq.h Rafael J. Wysocki
2016-03-22 1:51 ` [PATCH v6 5/7][Resend] cpufreq: Move governor symbols " Rafael J. Wysocki
2016-03-28 5:35 ` Viresh Kumar
2016-03-22 1:53 ` [PATCH v6 6/7][Resend] cpufreq: Support for fast frequency switching Rafael J. Wysocki
2016-03-26 1:12 ` Steve Muckle
2016-03-26 1:46 ` Rafael J. Wysocki
2016-03-27 1:27 ` Rafael J. Wysocki
2016-03-28 16:47 ` Steve Muckle
2016-03-29 12:10 ` Rafael J. Wysocki
2016-03-28 6:27 ` Viresh Kumar
2016-03-29 12:31 ` Rafael J. Wysocki
2016-03-28 7:03 ` Viresh Kumar
2016-03-29 12:10 ` Rafael J. Wysocki
2016-03-29 14:20 ` Viresh Kumar
2016-03-30 1:47 ` [Update][PATCH v7 6/7] " Rafael J. Wysocki
2016-03-30 5:07 ` Viresh Kumar
2016-03-30 11:28 ` Rafael J. Wysocki
2016-03-22 1:54 ` [PATCH v6 7/7][Resend] cpufreq: schedutil: New governor based on scheduler utilization data Rafael J. Wysocki
2016-03-26 1:12 ` Steve Muckle
2016-03-26 2:05 ` Rafael J. Wysocki
2016-03-27 1:36 ` Rafael J. Wysocki
2016-03-28 18:17 ` Steve Muckle
2016-03-29 12:23 ` Rafael J. Wysocki [this message]
2016-03-31 12:24 ` Peter Zijlstra
2016-03-31 12:32 ` Rafael J. Wysocki
2016-04-01 18:15 ` Steve Muckle
2016-03-28 9:03 ` Viresh Kumar
2016-03-29 12:58 ` Rafael J. Wysocki
2016-03-30 1:12 ` Rafael J. Wysocki
2016-03-31 12:28 ` Peter Zijlstra
2016-03-30 4:10 ` Viresh Kumar
2016-03-30 2:00 ` [Update][PATCH v7 7/7] " Rafael J. Wysocki
2016-03-30 5:30 ` Viresh Kumar
2016-03-30 11:31 ` Rafael J. Wysocki
2016-03-30 17:05 ` Steve Muckle
2016-03-30 17:24 ` Rafael J. Wysocki
2016-03-31 1:44 ` Steve Muckle
2016-03-31 12:12 ` Peter Zijlstra
2016-03-31 12:18 ` Rafael J. Wysocki
2016-03-31 12:42 ` Peter Zijlstra
2016-03-31 12:48 ` Peter Zijlstra
2016-04-01 17:49 ` Steve Muckle
2016-04-01 19:14 ` Rafael J. Wysocki
2016-04-01 19:23 ` Steve Muckle
2016-04-01 23:06 ` [Update][PATCH v8 " Rafael J. Wysocki
2016-04-02 1:09 ` Steve Muckle
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=1569749.Ubc4LvLySG@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=juri.lelli@arm.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mturquette@baylibre.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=steve.muckle@linaro.org \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.org \
/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®