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

[PATCH v6 14/19] xen/cpufreq: get performance policy from governor set via xenpm


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 11 Jul 2025 11:51:01 +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=F2xrCTmAriiyNcApbk66PtW1PjMrLOdQPPDHXCP2gL4=; b=Gt7SQqbpfXjGGIv1k92elusY/Z+bQMbyxIxB74thKGkMrZN76g+SHM4DQqz/p50t1GwqXotDD7bZ35jO0aG3n7Z1mzUIQIKXLGCXEU1jFZtT70IsPOgFvdbitnDyWqERGcBbeyYN15yV8VfDC/uWniQnP3mehE/YhwZ0NJcMo3bH9Ex12Q6h9peSGSR63YCl7L7LMJCn7IZ0Vzws6tJTyYaQUJfVz4hrIRuZJr2cQ3uHBHJp0JQb2Fs95xtY2CI98QIsf9snfsnxuSXJxK3GepJjbI/7vCyydeFXsz1++FRf/rakj9V72UHjp1s/7cveeT3plSsYrqIvvX1MgEthTw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bXwDSsp0HX9BoR3DcwXcSp8KoMgu3OBVZfjB42cIs2G1fKE9Ekpz1TrPeO2SgOJ9J7UMH5Zx6dpzrSgzzUaY7M9jSMyMeP4d+90F2+2wRfmGJg8pdNdbAC4UnVTejI0xXaLN6PAAO0QrQsklS1kpwqiVh6DvTB8Zt2s2NUYEOTPifDQK7tRcH4KVSWAVZwQxKnzpebRMYUzbJsj2YibrXjJ0EVymSoyBQSY+VxmbEaOfMUhQUuLeE3sp9BKcL+tzIxWIxwx2KtPqBp7BgtGLdGV0pVFVLtmLcD6H8kOKDIFY+DEFIYQTcRpMtTb2HtriGyxTpoAjgKwcoGgMIb8MKw==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 11 Jul 2025 04:01:11 +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.

ondemand and userspace are forbidden choices, and if users specify
such options, 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>
---
v4 -> v5:
- new commit
---
v5 -> v6:
- refactor warning message
---
 xen/drivers/acpi/pm-op.c      | 8 ++++++++
 xen/drivers/cpufreq/utility.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/xen/drivers/acpi/pm-op.c b/xen/drivers/acpi/pm-op.c
index d10f6db0e4..e616c3316a 100644
--- a/xen/drivers/acpi/pm-op.c
+++ b/xen/drivers/acpi/pm-op.c
@@ -205,6 +205,14 @@ static int set_cpufreq_gov(struct xen_sysctl_pm_op *op)
     if ( new_policy.governor == NULL )
         return -EINVAL;
 
+    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);
 }
 
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index 64bcc464f6..e2cc9ff2af 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -250,6 +250,7 @@ int __cpufreq_set_policy(struct cpufreq_policy *data,
     data->min = policy->min;
     data->max = policy->max;
     data->limits = policy->limits;
+    data->policy = policy->policy;
     if (cpufreq_driver.setpolicy)
         return alternative_call(cpufreq_driver.setpolicy, data);
 
-- 
2.34.1




 


Rackspace

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