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

[xen master] xen/cpufreq: get performance policy from governor set via xenpm



commit 983a15a36ec5aee89770f50316a4f6dcdcf245f6
Author:     Penny Zheng <Penny.Zheng@xxxxxxx>
AuthorDate: Thu Sep 25 09:21:07 2025 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Sep 25 09:21:07 2025 +0200

    xen/cpufreq: get performance policy from governor set via xenpm
    
    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>
---
 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);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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