From: Viresh Kumar <viresh.kumar@linaro.org>
To: Rafael Wysocki <rjw@rjwysocki.net>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vincent Guittot <vincent.guittot@linaro.org>,
smuckle.linux@gmail.com, juri.lelli@arm.com,
Morten.Rasmussen@arm.com, patrick.bellasi@arm.com,
eas-dev@lists.linaro.org, Viresh Kumar <viresh.kumar@linaro.org>
Subject: [RFC 6/9] sched: cpufreq: detect, process remote callbacks
Date: Thu, 9 Mar 2017 17:15:16 +0530 [thread overview]
Message-ID: <2e807adcbf0d5136876f9de48c62e9e2dd2a5b06.1489058244.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1489058244.git.viresh.kumar@linaro.org>
In-Reply-To: <cover.1489058244.git.viresh.kumar@linaro.org>
From: Steve Muckle <smuckle.linux@gmail.com>
A callback is considered remote if the target CPU is not the current CPU
and if it is not managed by the policy managing the current CPU or the
current CPU can't do DVFS on its behalf.
Queue the irq work for remote callbacks on the destination CPU. The irq
work will carry out the fast or slow switch as appropriate.
Signed-off-by: Steve Muckle <smuckle.linux@gmail.com>
[ vk: commit log, code cleanups, introduce dvfs_possible_from_any_cpu
and drop late callback support to avoid IPIs on remote CPUs. ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/cpufreq_schedutil.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index b168c31f1c8f..9bad579b6b08 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -100,11 +100,11 @@ static void sugov_fast_switch(struct cpufreq_policy *policy,
}
static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
- unsigned int next_freq)
+ int cpu, bool remote, unsigned int next_freq)
{
struct cpufreq_policy *policy = sg_policy->policy;
- if (policy->fast_switch_enabled) {
+ if (policy->fast_switch_enabled && !remote) {
if (sg_policy->next_freq == next_freq) {
trace_cpu_frequency(policy->cur, policy->cpu);
return;
@@ -116,7 +116,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
sg_policy->next_freq = next_freq;
sg_policy->last_freq_update_time = time;
sg_policy->work_in_progress = true;
- irq_work_queue(&sg_policy->irq_work);
+ irq_work_queue_on(&sg_policy->irq_work, cpu);
}
}
@@ -206,6 +206,20 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
struct cpufreq_policy *policy = sg_policy->policy;
unsigned long util, max;
unsigned int next_f;
+ int cpu, this_cpu = smp_processor_id();
+ bool remote;
+
+ if (policy->dvfs_possible_from_any_cpu) {
+ /*
+ * Avoid sending IPI to 'hook->cpu' if this CPU can change
+ * frequency on its behalf.
+ */
+ remote = false;
+ cpu = this_cpu;
+ } else {
+ cpu = hook->cpu;
+ remote = this_cpu != hook->cpu;
+ }
sugov_set_iowait_boost(sg_cpu, time, flags);
sg_cpu->last_update = time;
@@ -220,7 +234,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
sugov_iowait_boost(sg_cpu, &util, &max);
next_f = get_next_freq(sg_policy, util, max);
}
- sugov_update_commit(sg_policy, time, next_f);
+ sugov_update_commit(sg_policy, time, cpu, remote, next_f);
}
static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu)
@@ -269,8 +283,24 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
{
struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
struct sugov_policy *sg_policy = sg_cpu->sg_policy;
+ struct cpufreq_policy *policy = sg_policy->policy;
unsigned long util, max;
unsigned int next_f;
+ int cpu, this_cpu = smp_processor_id();
+ bool remote;
+
+ if (policy->dvfs_possible_from_any_cpu ||
+ cpumask_test_cpu(this_cpu, policy->cpus)) {
+ /*
+ * Avoid sending IPI to 'hook->cpu' if this CPU can change
+ * frequency on its behalf.
+ */
+ remote = false;
+ cpu = this_cpu;
+ } else {
+ cpu = hook->cpu;
+ remote = this_cpu != hook->cpu;
+ }
sugov_get_util(&util, &max, hook->cpu);
@@ -289,7 +319,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
else
next_f = sugov_next_freq_shared(sg_cpu);
- sugov_update_commit(sg_policy, time, next_f);
+ sugov_update_commit(sg_policy, time, cpu, remote, next_f);
}
raw_spin_unlock(&sg_policy->update_lock);
--
2.7.1.410.g6faf27b
next prev parent reply other threads:[~2017-03-09 11:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-09 11:45 [RFC 0/9] cpufreq: schedutil: Allow remote wakeups Viresh Kumar
2017-03-09 11:45 ` [RFC 1/9] sched: cpufreq: add cpu to update_util_data Viresh Kumar
2017-03-29 21:18 ` Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 2/9] irq_work: add irq_work_queue_on for !CONFIG_SMP Viresh Kumar
2017-03-29 21:20 ` Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 3/9] cpufreq: Add dvfs_possible_from_any_cpu policy flag Viresh Kumar
2017-03-29 21:22 ` Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 4/9] sched: cpufreq: extend irq work to support fast switches Viresh Kumar
2017-03-29 21:25 ` Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 5/9] sched: cpufreq: remove smp_processor_id() in remote paths Viresh Kumar
2017-03-29 21:28 ` Rafael J. Wysocki
2017-04-11 10:35 ` Viresh Kumar
2017-04-11 14:00 ` Rafael J. Wysocki
2017-04-12 14:26 ` Viresh Kumar
2017-04-12 22:53 ` Rafael J. Wysocki
2017-03-09 11:45 ` Viresh Kumar [this message]
2017-03-29 21:58 ` [RFC 6/9] sched: cpufreq: detect, process remote callbacks Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 7/9] cpufreq: governor: support scheduler cpufreq callbacks on remote CPUs Viresh Kumar
2017-03-29 22:14 ` Rafael J. Wysocki
2017-04-11 11:06 ` Viresh Kumar
2017-03-09 11:45 ` [RFC 8/9] intel_pstate: ignore " Viresh Kumar
2017-03-29 22:15 ` Rafael J. Wysocki
2017-03-09 11:45 ` [RFC 9/9] sched: cpufreq: enable remote sched cpufreq callbacks Viresh Kumar
2017-03-15 11:45 ` [RFC 0/9] cpufreq: schedutil: Allow remote wakeups Rafael J. Wysocki
2017-03-16 3:09 ` Viresh Kumar
2017-03-16 10:04 ` Rafael J. Wysocki
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=2e807adcbf0d5136876f9de48c62e9e2dd2a5b06.1489058244.git.viresh.kumar@linaro.org \
--to=viresh.kumar@linaro.org \
--cc=Morten.Rasmussen@arm.com \
--cc=eas-dev@lists.linaro.org \
--cc=juri.lelli@arm.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=patrick.bellasi@arm.com \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=smuckle.linux@gmail.com \
--cc=vincent.guittot@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;
as well as URLs for NNTP newsgroup(s).