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

[PATCH v6 15/19] tools/cpufreq: introduce helper to deal with CPPC-related parameters


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 11 Jul 2025 11:51:02 +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=x8Ck12KZjKIBi0141uA3E7Xx1pEuuUqreZFrdu0/Hqg=; b=tJCCa6Qxt8itsH77bKO+5KmTv0TQKmf0tExb7rYr20kRhfDbauspei9j/Cc9la4OOOFWBRVcxJHaYRH3ej/vxwDM8VD48uC2gXW2zRXWswWKTZg1pMVsaVMR+7riNt/ZDheLU8RPZO7TwE5/zSCO0L6Tg9ORg/OCSOXTCE+yRKtNMX8DYFiZyTRXrM+QyENINY8938vCp0zsCfImhDZxyh6gw/FOSBAK4oGlI1eRHCSixzMbGO9fSVnU4glQGzHMm3Zv/M/mh8zqu7haAtjQ+edsxzSBrJeX1ISQpgnskxFGzk6bb/+idgynLt90nsWHno+Aw8ZbskHpIgBwgx+3Xg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N1dolZwy/KVL4ro5/hD74KvVGn2ZwvauMEl6dSbZS+YkMsv9cXhC3a9qlj8aJhoKSsELa79yQ+h9Qz4fVJSfJZMbCmiZfpIJipIPxZVxA5KA/d6B/zNtt/1+XViXT6z3OU1i56nvj7Apo9P8RMAKWLLTqa+q+N8iYY3WqCvwpibSHNMbZ0doobyNLE0U9JNQ4mGE9y181okKSGNONK34kqe4SsL6sLfmvfV3EP9j9AGEZsjpDa52Wc9jeVJWdpfGXBZL7RnxYmywm175TRpgFeHtmq5629/laeoJ5o0rAH4uMGutynpMgdZzZ2hJl9uP5D6kMTH8DJQiunn2RLpoLg==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 11 Jul 2025 04:01:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

New helpers print_cppc_para() and get_cpufreq_cppc() are introduced to deal
with CPPC-related parameters, in order to be re-used when later exporting new
sub-op "get-cpufreq-cppc".

Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v5 -> v6:
- new commit
---
 tools/misc/xenpm.c       | 53 +++++++++++++++++++++-------------------
 xen/drivers/acpi/pm-op.c | 16 +++++++++---
 2 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
index 55b0b0c482..120e9eae22 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -799,6 +799,33 @@ static unsigned int calculate_activity_window(const 
xc_cppc_para_t *cppc,
     return mantissa * multiplier;
 }
 
+/* print out parameters about cpu cppc */
+static void print_cppc_para(unsigned int cpuid,
+                            const xc_cppc_para_t *cppc)
+{
+    printf("cppc variables       :\n");
+    printf("  hardware limits    : lowest [%"PRIu32"] lowest nonlinear 
[%"PRIu32"]\n",
+           cppc->lowest, cppc->lowest_nonlinear);
+    printf("                     : nominal [%"PRIu32"] highest [%"PRIu32"]\n",
+           cppc->nominal, cppc->highest);
+    printf("  configured limits  : min [%"PRIu32"] max [%"PRIu32"] energy perf 
[%"PRIu32"]\n",
+           cppc->minimum, cppc->maximum, cppc->energy_perf);
+
+    if ( cppc->features & XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW )
+    {
+        unsigned int activity_window;
+        const char *units;
+
+        activity_window = calculate_activity_window(cppc, &units);
+        printf("                     : activity_window [%"PRIu32" %s]\n",
+               activity_window, units);
+    }
+
+    printf("                     : desired [%"PRIu32"%s]\n",
+           cppc->desired,
+           cppc->desired ? "" : " hw autonomous");
+}
+
 /* print out parameters about cpu frequency */
 static void print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para 
*p_cpufreq)
 {
@@ -825,31 +852,7 @@ static void print_cpufreq_para(int cpuid, struct 
xc_get_cpufreq_para *p_cpufreq)
     printf("scaling_driver       : %s\n", p_cpufreq->scaling_driver);
 
     if ( hwp )
-    {
-        const xc_cppc_para_t *cppc = &p_cpufreq->u.cppc_para;
-
-        printf("cppc variables       :\n");
-        printf("  hardware limits    : lowest [%"PRIu32"] lowest nonlinear 
[%"PRIu32"]\n",
-               cppc->lowest, cppc->lowest_nonlinear);
-        printf("                     : nominal [%"PRIu32"] highest 
[%"PRIu32"]\n",
-               cppc->nominal, cppc->highest);
-        printf("  configured limits  : min [%"PRIu32"] max [%"PRIu32"] energy 
perf [%"PRIu32"]\n",
-               cppc->minimum, cppc->maximum, cppc->energy_perf);
-
-        if ( cppc->features & XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW )
-        {
-            unsigned int activity_window;
-            const char *units;
-
-            activity_window = calculate_activity_window(cppc, &units);
-            printf("                     : activity_window [%"PRIu32" %s]\n",
-                   activity_window, units);
-        }
-
-        printf("                     : desired [%"PRIu32"%s]\n",
-               cppc->desired,
-               cppc->desired ? "" : " hw autonomous");
-    }
+        print_cppc_para(cpuid, &p_cpufreq->u.cppc_para);
     else
     {
         if ( p_cpufreq->gov_num )
diff --git a/xen/drivers/acpi/pm-op.c b/xen/drivers/acpi/pm-op.c
index e616c3316a..acaa33561f 100644
--- a/xen/drivers/acpi/pm-op.c
+++ b/xen/drivers/acpi/pm-op.c
@@ -77,6 +77,17 @@ static int read_scaling_available_governors(char 
*scaling_available_governors,
     return 0;
 }
 
+static int get_cpufreq_cppc(unsigned int cpu,
+                            struct xen_get_cppc_para *cppc_para)
+{
+    int ret = -ENODEV;
+
+    if ( hwp_active() )
+        ret = get_hwp_para(cpu, cppc_para);
+
+    return ret;
+}
+
 static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
 {
     uint32_t ret = 0;
@@ -141,9 +152,8 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
     else
         strlcpy(op->u.get_para.scaling_driver, "Unknown", CPUFREQ_NAME_LEN);
 
-    if ( hwp_active() )
-        ret = get_hwp_para(policy->cpu, &op->u.get_para.u.cppc_para);
-    else
+    ret = get_cpufreq_cppc(op->cpuid, &op->u.get_para.u.cppc_para);
+    if ( ret == -ENODEV )
     {
         if ( !(scaling_available_governors =
                xzalloc_array(char, gov_num * CPUFREQ_NAME_LEN)) )
-- 
2.34.1




 


Rackspace

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