From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Pierre Gondois <pierre.gondois@arm.com>,
Christian Loehle <christian.loehle@arm.com>
Subject: [RFT][PATCH v1 1/8] cpufreq/sched: schedutil: Add helper for governor checks
Date: Wed, 16 Apr 2025 19:48:16 +0200 [thread overview]
Message-ID: <10640940.nUPlyArG6x@rjwysocki.net> (raw)
In-Reply-To: <3344336.aeNJFYEL58@rjwysocki.net>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Add a helper for checking if schedutil is the current governor for
a given cpufreq policy and use it in sched_is_eas_possible() to avoid
accessing cpufreq policy internals directly from there.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v0.3 -> v1
* Change the name of the new function to sugov_is_governor().
This patch is regarded as a cleanup for 6.16.
---
include/linux/cpufreq.h | 9 +++++++++
kernel/sched/cpufreq_schedutil.c | 9 +++++++--
kernel/sched/sched.h | 2 --
kernel/sched/topology.c | 6 +++---
4 files changed, 19 insertions(+), 7 deletions(-)
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -650,6 +650,15 @@
struct cpufreq_governor *cpufreq_default_governor(void);
struct cpufreq_governor *cpufreq_fallback_governor(void);
+#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL
+bool sugov_is_governor(struct cpufreq_policy *policy);
+#else
+static inline bool sugov_is_governor(struct cpufreq_policy *policy)
+{
+ return false;
+}
+#endif
+
static inline void cpufreq_policy_apply_limits(struct cpufreq_policy *policy)
{
if (policy->max < policy->cur)
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -630,7 +630,7 @@
/********************** cpufreq governor interface *********************/
-struct cpufreq_governor schedutil_gov;
+static struct cpufreq_governor schedutil_gov;
static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *policy)
{
@@ -909,7 +909,7 @@
WRITE_ONCE(sg_policy->limits_changed, true);
}
-struct cpufreq_governor schedutil_gov = {
+static struct cpufreq_governor schedutil_gov = {
.name = "schedutil",
.owner = THIS_MODULE,
.flags = CPUFREQ_GOV_DYNAMIC_SWITCHING,
@@ -927,4 +927,9 @@
}
#endif
+bool sugov_is_governor(struct cpufreq_policy *policy)
+{
+ return policy->governor == &schedutil_gov;
+}
+
cpufreq_governor_init(schedutil_gov);
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -3509,8 +3509,6 @@
return static_branch_unlikely(&sched_energy_present);
}
-extern struct cpufreq_governor schedutil_gov;
-
#else /* ! (CONFIG_ENERGY_MODEL && CONFIG_CPU_FREQ_GOV_SCHEDUTIL) */
#define perf_domain_span(pd) NULL
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -213,7 +213,7 @@
{
bool any_asym_capacity = false;
struct cpufreq_policy *policy;
- struct cpufreq_governor *gov;
+ bool policy_is_ready;
int i;
/* EAS is enabled for asymmetric CPU capacity topologies. */
@@ -258,9 +258,9 @@
}
return false;
}
- gov = policy->governor;
+ policy_is_ready = sugov_is_governor(policy);
cpufreq_cpu_put(policy);
- if (gov != &schedutil_gov) {
+ if (!policy_is_ready) {
if (sched_debug()) {
pr_info("rd %*pbl: Checking EAS, schedutil is mandatory\n",
cpumask_pr_args(cpu_mask));
next prev parent reply other threads:[~2025-04-16 18:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 17:44 [RFT][PATCH v1 0/8] cpufreq: intel_pstate: Enable EAS on hybrid platforms without SMT Rafael J. Wysocki
2025-04-16 17:48 ` Rafael J. Wysocki [this message]
2025-04-17 12:23 ` [RFT][PATCH v1 1/8] cpufreq/sched: schedutil: Add helper for governor checks Christian Loehle
2025-04-16 17:59 ` [RFT][PATCH v1 2/8] cpufreq/sched: Move cpufreq-specific EAS checks to cpufreq Rafael J. Wysocki
2025-04-17 12:28 ` Christian Loehle
2025-04-16 18:01 ` [RFT][PATCH v1 3/8] cpufreq/sched: Allow .setpolicy() cpufreq drivers to enable EAS Rafael J. Wysocki
2025-04-17 12:19 ` Christian Loehle
2025-04-17 13:01 ` Rafael J. Wysocki
2025-04-17 13:03 ` Christian Loehle
2025-04-16 18:04 ` [RFT][PATCH v1 4/8] PM: EM: Move CPU capacity check to em_adjust_new_capacity() Rafael J. Wysocki
2025-04-16 18:06 ` [RFT][PATCH v1 5/8] PM: EM: Introduce em_adjust_cpu_capacity() Rafael J. Wysocki
2025-04-27 14:01 ` Dietmar Eggemann
2025-04-30 19:23 ` Rafael J. Wysocki
2025-05-01 12:30 ` Dietmar Eggemann
2025-05-06 19:46 ` Rafael J. Wysocki
2025-04-16 18:09 ` [RFT][PATCH v1 6/8] cpufreq: intel_pstate: EAS support for hybrid platforms Rafael J. Wysocki
2025-04-16 18:10 ` [RFT][PATCH v1 7/8] cpufreq: intel_pstate: Align perf domains with L2 cache Rafael J. Wysocki
2025-04-17 12:42 ` Christian Loehle
2025-04-27 16:23 ` Dietmar Eggemann
2025-04-30 19:29 ` Rafael J. Wysocki
2025-05-01 12:30 ` Dietmar Eggemann
2025-04-16 18:12 ` [RFT][PATCH v1 8/8] cpufreq: intel_pstate: EAS: Increase cost for CPUs using L3 cache Rafael J. Wysocki
2025-04-25 21:32 ` Christian Loehle
2025-04-25 21:39 ` Rafael J. Wysocki
2025-04-18 9:58 ` [RFT][PATCH v1 0/8] cpufreq: intel_pstate: Enable EAS on hybrid platforms without SMT Christian Loehle
2025-04-18 19:52 ` Rafael J. Wysocki
2025-05-12 13:23 ` [PATCH v1] cpufreq: Drop policy locking from cpufreq_policy_is_good_for_eas() 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=10640940.nUPlyArG6x@rjwysocki.net \
--to=rjw@rjwysocki.net \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=srinivas.pandruvada@linux.intel.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