lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed,  1 Jul 2020 10:07:44 +0100
From:   Ionela Voinescu <ionela.voinescu@....com>
To:     rjw@...ysocki.net, viresh.kumar@...aro.org,
        catalin.marinas@....com, sudeep.holla@....com, will@...nel.org,
        linux@...linux.org.uk, valentin.schneider@....com
Cc:     mingo@...hat.com, peterz@...radead.org, dietmar.eggemann@....com,
        ionela.voinescu@....com, linux-pm@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/8] cpufreq: allow drivers to flag custom support for freq invariance

The scheduler's Frequency Invariance Engine (FIE) is providing a
frequency scale correction factor that helps achieve more accurate
load-tracking by conveying information about the currently selected
frequency relative to the maximum supported frequency of a CPU.

In some cases this is achieved by passing information from cpufreq
drivers about the frequency selection done by cpufreq.

Given that most drivers follow a similar process of selecting and
setting of frequency, there is a strong case for moving the setting
of the frequency scale factor from the cpufreq drivers frequency
switch callbacks (target_index() and fast_switch()), to the cpufreq
core functions that call them.

In preparation for this, acknowledge that there are still drivers
who's frequency setting process is custom and therefore these drivers
will want to provide and flag custom support for the setting of the
scheduler's frequency invariance (FI) scale factor as well. Prepare
for this by introducing a new flag: CPUFREQ_CUSTOM_SET_FREQ_SCALE.

Examples of users of this flag are:
 - drivers that do not implement the callbacks that lend themselves
   to triggering the setting of the FI scale factor,
 - drivers that implement the appropriate callbacks but which have
   an atypical implementation.

Currently, given that all drivers call arch_set_freq_scale() directly,
flag all users with CPUFREQ_CUSTOM_SET_FREQ_SCALE. These driver changes
are also useful to maintain bisection between the FI switch from the
drivers to the core.

Signed-off-by: Ionela Voinescu <ionela.voinescu@....com>
Cc: Rafael J. Wysocki <rjw@...ysocki.net>
Cc: Viresh Kumar <viresh.kumar@...aro.org>
---
 drivers/cpufreq/cpufreq-dt.c           |  3 ++-
 drivers/cpufreq/qcom-cpufreq-hw.c      |  3 ++-
 drivers/cpufreq/scmi-cpufreq.c         |  3 ++-
 drivers/cpufreq/scpi-cpufreq.c         |  3 ++-
 drivers/cpufreq/vexpress-spc-cpufreq.c |  3 ++-
 include/linux/cpufreq.h                | 10 +++++++++-
 6 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 944d7b45afe9..8e0571a49d1e 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -331,7 +331,8 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
 
 static struct cpufreq_driver dt_cpufreq_driver = {
 	.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-		 CPUFREQ_IS_COOLING_DEV,
+		 CPUFREQ_IS_COOLING_DEV |
+		 CPUFREQ_CUSTOM_SET_FREQ_SCALE,
 	.verify = cpufreq_generic_frequency_table_verify,
 	.target_index = set_target,
 	.get = cpufreq_generic_get,
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 573630c23aca..e13780beb373 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -337,7 +337,8 @@ static struct freq_attr *qcom_cpufreq_hw_attr[] = {
 static struct cpufreq_driver cpufreq_qcom_hw_driver = {
 	.flags		= CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
 			  CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-			  CPUFREQ_IS_COOLING_DEV,
+			  CPUFREQ_IS_COOLING_DEV |
+			  CPUFREQ_CUSTOM_SET_FREQ_SCALE,
 	.verify		= cpufreq_generic_frequency_table_verify,
 	.target_index	= qcom_cpufreq_hw_target_index,
 	.get		= qcom_cpufreq_hw_get,
diff --git a/drivers/cpufreq/scmi-cpufreq.c b/drivers/cpufreq/scmi-cpufreq.c
index fb42e3390377..16ab4ecc75e4 100644
--- a/drivers/cpufreq/scmi-cpufreq.c
+++ b/drivers/cpufreq/scmi-cpufreq.c
@@ -223,7 +223,8 @@ static struct cpufreq_driver scmi_cpufreq_driver = {
 	.name	= "scmi",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
 		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-		  CPUFREQ_IS_COOLING_DEV,
+		  CPUFREQ_IS_COOLING_DEV |
+		  CPUFREQ_CUSTOM_SET_FREQ_SCALE,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.target_index	= scmi_cpufreq_set_target,
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c
index b0f5388b8854..6b5f56dc3ca3 100644
--- a/drivers/cpufreq/scpi-cpufreq.c
+++ b/drivers/cpufreq/scpi-cpufreq.c
@@ -197,7 +197,8 @@ static struct cpufreq_driver scpi_cpufreq_driver = {
 	.name	= "scpi-cpufreq",
 	.flags	= CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
 		  CPUFREQ_NEED_INITIAL_FREQ_CHECK |
-		  CPUFREQ_IS_COOLING_DEV,
+		  CPUFREQ_IS_COOLING_DEV |
+		  CPUFREQ_CUSTOM_SET_FREQ_SCALE,
 	.verify	= cpufreq_generic_frequency_table_verify,
 	.attr	= cpufreq_generic_attr,
 	.get	= scpi_cpufreq_get_rate,
diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c
index 4e8b1dee7c9a..e0a1a3367ec5 100644
--- a/drivers/cpufreq/vexpress-spc-cpufreq.c
+++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
@@ -496,7 +496,8 @@ static struct cpufreq_driver ve_spc_cpufreq_driver = {
 	.name			= "vexpress-spc",
 	.flags			= CPUFREQ_STICKY |
 					CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
-					CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+					CPUFREQ_NEED_INITIAL_FREQ_CHECK |
+					CPUFREQ_CUSTOM_SET_FREQ_SCALE,
 	.verify			= cpufreq_generic_frequency_table_verify,
 	.target_index		= ve_spc_cpufreq_set_target,
 	.get			= ve_spc_cpufreq_get_rate,
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 3494f6763597..42668588f9f8 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -293,7 +293,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
 
 struct cpufreq_driver {
 	char		name[CPUFREQ_NAME_LEN];
-	u8		flags;
+	u16		flags;
 	void		*driver_data;
 
 	/* needed by all drivers */
@@ -417,6 +417,14 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_IS_COOLING_DEV			BIT(7)
 
+/*
+ * Set by drivers which implement the necessary calls to the scheduler's
+ * frequency invariance engine. The use of this flag will result in the
+ * default arch_set_freq_scale calls being skipped in favour of custom
+ * driver calls.
+ */
+#define CPUFREQ_CUSTOM_SET_FREQ_SCALE		BIT(8)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ