mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Quentin Perret <qperret@google.com>
To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	x86@kernel.org, hpa@zytor.com, sudeep.holla@arm.com,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	viresh.kumar@linaro.org, peterz@infradead.org,
	juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, mcgrof@kernel.org,
	keescook@chromium.org, yzaikin@google.com, fweisbec@gmail.com,
	tkjos@google.com, kernel-team@android.com, qperret@google.com
Subject: [PATCH 03/14] sched: cpufreq: Introduce 'want_eas' governor flag
Date: Thu,  7 May 2020 19:10:01 +0100	[thread overview]
Message-ID: <20200507181012.29791-4-qperret@google.com> (raw)
In-Reply-To: <20200507181012.29791-1-qperret@google.com>

The EAS topology code requires the usage of schedutil on all CPUs of an
rd to actually enable EAS balancing. However, the check implementing
this references the schedutil_gov struct directly, which makes having
schedutil as a module impractical.

To prepare the ground for this modularization, introduce a new
'want_eas' flag in the cpufreq_governor struct, set it for schedutil
only, and make sure to check it from the EAS topology code.

Signed-off-by: Quentin Perret <qperret@google.com>
---
 include/linux/cpufreq.h          |  4 ++++
 kernel/sched/cpufreq_schedutil.c |  5 ++++-
 kernel/sched/topology.c          | 12 ++++++------
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index f7240251a949..267cc3b624da 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -560,6 +560,10 @@ struct cpufreq_governor {
 	bool			dynamic_switching;
 	struct list_head	governor_list;
 	struct module		*owner;
+
+#ifdef CONFIG_ENERGY_MODEL
+	bool			want_eas;
+#endif /* CONFIG_ENERGY_MODEL */
 };
 
 /* Pass a target to the cpufreq driver */
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index ebd5d30f0861..c5e5045f7c81 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -888,6 +888,9 @@ struct cpufreq_governor schedutil_gov = {
 	.start			= sugov_start,
 	.stop			= sugov_stop,
 	.limits			= sugov_limits,
+#ifdef CONFIG_ENERGY_MODEL
+	.want_eas		= true,
+#endif /* CONFIG_ENERGY_MODEL */
 };
 
 #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL
@@ -924,7 +927,7 @@ static DECLARE_WORK(rebuild_sd_work, rebuild_sd_workfn);
 void sched_cpufreq_governor_change(struct cpufreq_policy *policy,
 				  struct cpufreq_governor *old_gov)
 {
-	if (old_gov == &schedutil_gov || policy->governor == &schedutil_gov) {
+	if ((old_gov && old_gov->want_eas) || policy->governor->want_eas) {
 		/*
 		 * When called from the cpufreq_register_driver() path, the
 		 * cpu_hotplug_lock is already held, so use a work item to
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 8344757bba6e..b905f2e8d9b2 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -319,7 +319,8 @@ static void sched_energy_set(bool has_eas)
  *    2. the SD_ASYM_CPUCAPACITY flag is set in the sched_domain hierarchy.
  *    3. no SMT is detected.
  *    4. the EM complexity is low enough to keep scheduling overheads low;
- *    5. schedutil is driving the frequency of all CPUs of the rd;
+ *    5. an EAS-compatible CPUfreq governor (schedutil) is driving the frequency
+ *       of all CPUs of the rd;
  *
  * The complexity of the Energy Model is defined as:
  *
@@ -339,7 +340,6 @@ static void sched_energy_set(bool has_eas)
  */
 #define EM_MAX_COMPLEXITY 2048
 
-extern struct cpufreq_governor schedutil_gov;
 static bool build_perf_domains(const struct cpumask *cpu_map)
 {
 	int i, nr_pd = 0, nr_cs = 0, nr_cpus = cpumask_weight(cpu_map);
@@ -347,7 +347,7 @@ static bool build_perf_domains(const struct cpumask *cpu_map)
 	int cpu = cpumask_first(cpu_map);
 	struct root_domain *rd = cpu_rq(cpu)->rd;
 	struct cpufreq_policy *policy;
-	struct cpufreq_governor *gov;
+	bool want_eas;
 
 	if (!sysctl_sched_energy_aware)
 		goto free;
@@ -377,11 +377,11 @@ static bool build_perf_domains(const struct cpumask *cpu_map)
 		policy = cpufreq_cpu_get(i);
 		if (!policy)
 			goto free;
-		gov = policy->governor;
+		want_eas = policy->governor && policy->governor->want_eas;
 		cpufreq_cpu_put(policy);
-		if (gov != &schedutil_gov) {
+		if (!want_eas) {
 			if (rd->pd)
-				pr_warn("rd %*pbl: Disabling EAS, schedutil is mandatory\n",
+				pr_warn("rd %*pbl: Disabling EAS because of incompatible CPUFreq governor\n",
 						cpumask_pr_args(cpu_map));
 			goto free;
 		}
-- 
2.26.2.526.g744177e7f7-goog


  parent reply	other threads:[~2020-05-07 18:10 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 18:09 [PATCH 00/14] Modularize schedutil Quentin Perret
2020-05-07 18:09 ` [PATCH 01/14] sched: Provide sched_set_deadline() Quentin Perret
2020-05-07 18:10 ` [PATCH 02/14] sched: cpufreq: Use sched_set_deadline() from sugov Quentin Perret
2020-05-07 18:10 ` Quentin Perret [this message]
2020-05-07 18:10 ` [PATCH 04/14] sched: cpufreq: Move sched_cpufreq_governor_change() Quentin Perret
2020-05-08  5:35   ` Pavan Kondeti
2020-05-08 13:18     ` Quentin Perret
2020-05-07 18:10 ` [PATCH 05/14] sched: cpufreq: Move schedutil_cpu_util() Quentin Perret
2020-05-07 18:10 ` [PATCH 06/14] arch_topology: Export cpu_scale per-cpu array Quentin Perret
2020-05-07 18:10 ` [PATCH 07/14] kthread: Export kthread_bind_mask() Quentin Perret
2020-05-07 18:10 ` [PATCH 08/14] sched/core: Export runqueues per-cpu array Quentin Perret
2020-05-08  8:07   ` Peter Zijlstra
2020-05-08 10:04     ` Quentin Perret
2020-05-07 18:10 ` [PATCH 09/14] sched/cpufreq: Export cpufreq_this_cpu_can_update() Quentin Perret
2020-05-07 18:10 ` [PATCH 10/14] sched/fair: Export cpu_util_freq() Quentin Perret
2020-05-07 18:10 ` [PATCH 11/14] tick/sched: Export tick_nohz_get_idle_calls_cpu Quentin Perret
2020-05-07 18:10 ` [PATCH 12/14] x86: Export arch_scale_freq_key Quentin Perret
2020-05-07 18:10 ` [PATCH 13/14] sched: cpufreq: Use IS_ENABLED() for schedutil Quentin Perret
2020-05-08  5:30   ` Pavan Kondeti
2020-05-08 13:21     ` Quentin Perret
2020-05-09  2:43       ` Pavan Kondeti
2020-05-07 18:10 ` [PATCH 14/14] sched: cpufreq: Modularize schedutil Quentin Perret
2020-05-07 21:34 ` [PATCH 00/14] " Valentin Schneider
2020-05-08 13:15   ` Quentin Perret
2020-05-08 14:52     ` Valentin Schneider
2020-05-08  5:33 ` Viresh Kumar
2020-05-08 13:18   ` Quentin Perret
2020-05-08  8:11 ` Peter Zijlstra
2020-05-08 10:37   ` Greg KH
2020-05-08 11:16     ` Quentin Perret
2020-05-08 11:31       ` Peter Zijlstra
2020-05-08 13:05         ` Quentin Perret
2020-05-08 13:40           ` Rafael J. Wysocki
2020-05-11  9:00             ` Quentin Perret
2020-05-11 15:26               ` Rafael J. Wysocki
2020-05-12  9:21                 ` Quentin Perret
2020-05-12 10:25                   ` Rafael J. Wysocki
2020-05-12 13:58                     ` Quentin Perret
2020-05-12 14:08                       ` Rafael J. Wysocki
2020-05-12 15:11                         ` Quentin Perret
2020-05-12 15:30                           ` Rafael J. Wysocki
2020-05-12 15:49                             ` Joel Fernandes
2020-05-13  8:57                               ` Quentin Perret
2020-05-12 16:26                             ` Quentin Perret
2020-05-12 17:30                               ` Rafael J. Wysocki
2020-05-13  9:41                                 ` Quentin Perret
2020-05-13 10:02                                   ` Greg KH
2020-05-13 10:06                                     ` Quentin Perret
2020-05-13 10:24                                       ` Greg KH
2020-05-08 14:09           ` Peter Zijlstra
2020-05-11  9:12             ` Quentin Perret
2020-05-08 11:26     ` Peter Zijlstra
2020-05-11  5:21       ` Viresh Kumar

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=20200507181012.29791-4-qperret@google.com \
    --to=qperret@google.com \
    --cc=bp@alien8.de \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=fweisbec@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=juri.lelli@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sudeep.holla@arm.com \
    --cc=tglx@linutronix.de \
    --cc=tkjos@google.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=x86@kernel.org \
    --cc=yzaikin@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