[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 06/11] xen/cpufreq: introduce policy type when cpufreq_driver->setpolicy exists


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 3 Dec 2024 16:11:06 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l+yjn6tY8kv6aWZsbjG/GS2xunJRw06lAQvR1V0lj7o=; b=PMmVmgrgHmCuuc/6I9vCJwPCQxSVIdb9bTfrA10/mbiK5unGKd9CAa/DSV/sDIS2OAhlzTyrHwbyToYrnY0b+RU1R6P1vQ+X/i6yb45PNLNT6qVtYWbjc+70cm0FoLpYRxl4PcWCy94w+GMrYYJxnqt+aCr2ArPE9OJkh+/WnpsmOLiW8WS3Rl2HT8O8Y7ni0bQKcB1EGnvaGs6JFCPyZneNopC9Z6kj1wLsqD3geUWFn3Qh2exnhhYVw7OWr8i2XwBXTiufbyT6JtvVA03gfnF4WRzYvknpGdYxJvWfqVJRwDI3FzyCBLhBGuS3jt5E3qQh2xMlyB7W6z92oGa7og==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sQXvPqpVS1eu5eOyVus+74kxKYVsawh3Ul15YgJ4U8pgzzy666/FEfI8WWSwh/MFTD4vZL5iQcDv/75TYK1zBdz2TahQVgrrAchvDobjtmSHOyl75EhN+h4ndJbWDf3f3b+R9agdei04WLqmb4YZd7plNj4X8U4rwNHI9xB64t3njPiEig723eSVPt6nTZnVDQ4TgaTTPnrEd30RRVO+G6KluQLHfC8IRLpCIPIRGVA/M890aG2P4BOgPZ6/cKoaDkvGitt7ThU1N1cm+Epnp5ZPyMgTsRPTPh3bYZgl/KHYNmAU/LCB2I0HLo6J6D2TNoauFOYfiaYaoSpzl359Hg==
  • Cc: <stefano.stabellini@xxxxxxx>, <Ray.Huang@xxxxxxx>, <Xenia.Ragiadakou@xxxxxxx>, <Jason.Andryuk@xxxxxxx>, <penny.zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>
  • Delivery-date: Tue, 03 Dec 2024 08:22:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Penny Zheng <penny.zheng@xxxxxxx>

If cpufreq_driver->target exists, the ->governor decides what frequency
within the limits is used. But when cpufreq_driver->setpolicy exists,
the CPUFreq scaling driver bypasses the governor layer and implement
their own performance scaling algorithms. And we introduce the following
two generic policies CPUFREQ_POLICY_POWERSAVE and CPUFREQ_POLICY_PERFORMANCE,
to have 1:1 map with governor info, to still benefit from cpufreq_opt_governor
cmdline.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
 xen/drivers/cpufreq/utility.c      | 11 +++++++++++
 xen/include/acpi/cpufreq/cpufreq.h | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index e690a484f1..2503ce6243 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -484,3 +484,14 @@ int __cpufreq_set_policy(struct cpufreq_policy *data,
 
     return __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
 }
+
+unsigned int cpufreq_parse_policy(struct cpufreq_governor *gov)
+{
+    if ( !strncasecmp(gov->name, "performance", CPUFREQ_NAME_LEN) )
+        return CPUFREQ_POLICY_PERFORMANCE;
+
+    if ( !strncasecmp(gov->name, "powersave", CPUFREQ_NAME_LEN) )
+        return CPUFREQ_POLICY_POWERSAVE;
+
+    return CPUFREQ_POLICY_UNKNOWN;
+}
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index acf133430b..cad27f6811 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -133,6 +133,17 @@ extern int cpufreq_register_governor(struct 
cpufreq_governor *governor);
 extern struct cpufreq_governor *__find_governor(const char *governor);
 #define CPUFREQ_DEFAULT_GOVERNOR &cpufreq_gov_dbs
 
+#define CPUFREQ_POLICY_UNKNOWN      0
+/*
+ * If cpufreq_driver->target() exists, the ->governor decides what frequency
+ * within the limits is used. If cpufreq_driver->setpolicy() exists, these
+ * two generic policies are available:
+ */
+#define CPUFREQ_POLICY_POWERSAVE    1
+#define CPUFREQ_POLICY_PERFORMANCE  2
+
+unsigned int cpufreq_parse_policy(struct cpufreq_governor *gov);
+
 /* pass a target to the cpufreq driver */
 extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
                                    unsigned int target_freq,
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.