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

[PATCH v5 12/18] xen/cpufreq: get performance policy from governor set via xenpm


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 27 May 2025 16:48:27 +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=uKMq5MghF8UFPlQJDia7shL8Q+N/pOobWNyzD8HVQKI=; b=mAZ3azt71GQbQnMIuaOFsHCuE2+su7gCdnHmS60eSR48e6W/TMYlRg2E8TC8VAlUxBpx89h9sykNWqsL24xkaARSmz8NBsiPbXI4nPotPORZzsI8eCqc0LERuSbfrhSQ4gbTbqH2EULv23+KwFoCbh5amSWuxpurXMufS/7GZUcYptq47PYDR9LV1g9AO7QjLTuLHsxDz0L6zWtkixoAt/RUlxOqhDsoHZyEvMAbNTI83ty/YIAWTV/JlNQuGl6atkAtlg4rPtpcb4E+5fio/g49gB6VbcLtDrLrStRgNhtfMlgL/4ZxgZPg/7f2NH6K6p3ah/yidMsBHBCBj7uz+g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XMmlld2VPjyKlHcYfHGImSreZGxmHsc5X831ga8NQnUA8l2pujC4idddpvb3q5pWwKg9RdHaHw1zpqZN/RuZjUov4C3/9H1Ibr8l0pqdurbBvTqQI3mNM61ysTQco6ZuzNCe55/uWxFqULbrqMFV2IaZFONUXxX5Gyn2nS6o118tXsWmQ8xWn/M8zyumB4fG1GoYokaN+EeN0UltAN6JqVRrPHalGL8j2O/YbCZFgNYeRLr4jj2N4ZH1myz8C4Ui8n8yJDd7V1TTWcuAP3nx1W1SBBlAUcaBkctH4j1Mro04beNHac1PI2io4ujbIx+ZzOv3CugQBiFxMlZKKQdeBw==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Tue, 27 May 2025 08:50:43 +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.
If user chooses powersave governor, they want the least power consumption.
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, but also error out.

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v4 -> v5:
- new commit
---
 xen/drivers/acpi/pmstat.c     | 8 ++++++++
 xen/drivers/cpufreq/utility.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index 330bc3a1c2..514475cf5c 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -319,6 +319,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, and users shall 
write epp values to deliver preference towards performance over efficiency",
+               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 2617581125..734cd84be1 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -456,6 +456,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®.