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

[PATCH v10 4/8] xen/cpufreq: get performance policy from governor set via xenpm


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 23 Sep 2025 12:38:22 +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=wwwi0tW4Ht3ef4KEnk99tP23MKB3LmcikYL/tmBwt+Y=; b=Q4BIAofmkcH1u4DWo1V8b65FUYai57bK/apOoWKrCHwJExH+PT5cOTEC2fWVMTfdZuh7D9mxSyOkyvhArF4w+8Zj+rfLTDat53GTcJGnFsxaziE3+o6qgo8XlxsBImjmbUm8Dvm49C8M+lB5PDABn/1SCVlivEwX4s2gKAJX4OGpDZSvcALpnYD3ToSTM6FYBuM2G+EsCnth9AC2s0pOsv8HsTszRNRQrz85g3EKWSXerKTtb+cb3zy7GD6KTD5eyRrLkBnj+mAN5qcT0aNwNTnSCZ7dhODJN+6ZcaiFJAQeNozn3KEjWdXMVU12WYbj/nmV/kHkrVtAAV8HeIQ41g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lNcZiBw+6a7X0e+90Q098D1T7AC4Sn/x6OENPZrNj189KVKYeNn679bNHXKccFaTeHR2qWfkwWYSUBWqXu+9Z1DTGrm2QtSCgqaax0c5aHhO1G6FJah1d0YZxdXqk5JTZ26IUnSALmLnwfI2gHZCEp6odnWqwHcHTHGffa/1017zIifi4c0LJhpIpoFbGKj4gGh+c3F4QFAVAMHN5svZu3Gb2wgEpkPrmbzuRflcnvyo1eCtLBFKJRt7UtHTxId6C8ShBoCvytrzOpNkCgqWHq3PBrVj9P+jpPATKv7G3BdOg88d1q9VLZDgETtmr8VBUnrRU6xCCQWWDREd6rxqzQ==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Tue, 23 Sep 2025 04:39:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Even if Xen governor is not used in amd-cppc active mode, we could
somehow deduce which performance policy (CPUFREQ_POLICY_xxx) user wants to
apply through which governor they choose, such as:
If user chooses performance governor, they want maximum performance, then
the policy shall be CPUFREQ_POLICY_PERFORMANCE
If user chooses powersave governor, they want the least power consumption,
then the policy shall be CPUFREQ_POLICY_POWERSAVE
Function cpufreq_policy_from_governor() is responsible for above transition,
and it shall be also effective when users setting new governor through xenpm.

Userspace is a forbidden choice, and if users specify such option, we shall
not only give warning message to suggest using "xenpm set-cpufreq-cppc", but
also error out.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v4 -> v5:
- new commit
---
v5 -> v6:
- refactor warning message
---
v6 -> v7:
- move policy->policy set where it firstly gets introduced
- refactor commit message
---
v7 -> v8:
- policy transition is only limited in CPPC mode
---
 xen/drivers/acpi/pm-op.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/xen/drivers/acpi/pm-op.c b/xen/drivers/acpi/pm-op.c
index 2f516e62b1..a7eaf29c31 100644
--- a/xen/drivers/acpi/pm-op.c
+++ b/xen/drivers/acpi/pm-op.c
@@ -207,6 +207,17 @@ static int set_cpufreq_gov(struct xen_sysctl_pm_op *op)
     if ( new_policy.governor == NULL )
         return -EINVAL;
 
+    if ( processor_pminfo[op->cpuid]->init & XEN_CPPC_INIT )
+    {
+        new_policy.policy = cpufreq_policy_from_governor(new_policy.governor);
+        if ( new_policy.policy == CPUFREQ_POLICY_UNKNOWN )
+        {
+            printk("Failed to get performance policy from %s, Try \"xenpm 
set-cpufreq-cppc\"\n",
+                   new_policy.governor->name);
+            return -EINVAL;
+        }
+    }
+
     return __cpufreq_set_policy(old_policy, &new_policy);
 }
 
-- 
2.34.1




 


Rackspace

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