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

RE: [PATCH v4 12/15] tools/xenpm: Print CPPC parameters for amd-cppc driver


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Fri, 9 May 2025 06:36:53 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=hd10w4jlfwI4deCty2vaPhalV31ZNZ5V6MfJegapS/o=; b=UcPrKdKfHw67xHC1XywGWKxG5b5JszedhZpn9muYSJ+UiTbLU/SZeO8X4mkOERs4O5hCUF5lzdjx0xSqWiRZhXHWCji8riMDd4xIs47gxjAQTFStdpJECsguxcQ1LLSBwQc6yjlVq1ngML+EnZ9DWKtZAygmXytgxVfjofZ3RWXWQwU9evKL7rPYcJsnOwjRJ3LbsrgeoYan2LMPKZn8JdPWu5LeXrtgyPRR1Xu33XtY5y/0v4oGXFNjIs/8gk0F5vZefNXCVqhILq2xhTy5myZ6lBjpN4YdCdCjWK4p6le2dX745zai+alOsODHpDUCOxdz9JabpktUZa/o3nwFfA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W2q8bOd3sGP1ZVVwaXNA8baht9aiim6Yr7PtGI0N2wXG8BuqNrTAWVKVckC/jPAc3PDDEkjEP1GY8xCvPraU7VjFfZvT3Vn9jDa/HdU3Nq0irAZmNRpTGXSvFJeu9VWgJczjtC6NK5ztSBAxKNcPI91PxA7SDS//IlYHuLRO1lexZsWmR51jAXApa+fkR4a0cfZn6+oZ4+dh9e39827Ugzvbt3KZU9AlDjQk31z8mgcX2SQwuHemlZDmXb1x5n4G1bS/iaSLRq+5pxnGJRn/Wu2gggyOhljGk6/ae/d/L7kZ/coneGDtgmiWX8S6mnsDHllI8o/f72ebMvp3ff78Pw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 09 May 2025 06:37:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_ActionId=60030911-e914-41fa-8d24-07a684a6c104;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_ContentBits=0;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Enabled=true;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Method=Privileged;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Name=Open Source;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SetDate=2025-05-09T06:36:45Z;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Tag=10, 0, 1, 1;
  • Thread-index: AQHbrRCuBHJz/5ZpqUqHhc0gdq6hGrO8VLYAgA1zbxA=
  • Thread-topic: [PATCH v4 12/15] tools/xenpm: Print CPPC parameters for amd-cppc driver

[Public]

Hi,

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Wednesday, April 30, 2025 9:55 PM
> To: Penny, Zheng <penny.zheng@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Anthony PERARD
> <anthony.perard@xxxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v4 12/15] tools/xenpm: Print CPPC parameters for amd-cppc
> driver
>
> On 14.04.2025 09:40, Penny Zheng wrote:
> > HWP, amd-cppc, amd-cppc-epp are all the implementation of ACPI CPPC
> > (Collaborative Processor Performace Control), so we introduce
> > cppc_mode flag to print CPPC-related para.
> >
> > And HWP and amd-cppc-epp are both governor-less driver, so we
> > introduce hw_auto flag to bypass governor-related print.
>
> But in the EPP driver you use the information which governor is active.
>

We want to have a one-one mapping between governor and epp value, such as,
If users choose performance governor, no matter via "xenpm" or cmdline, users 
want maximum performance,
We set epp with 0 to meet the expectation.
And if users choose powersave governor, users want the least power consumption, 
then we shall set
epp with 255 to meet the expectation.
Ondemand is a tricky part, hmmmm, I don't know which value is suitable for it, 
the medium one? So I neglect it in the first place
I'll add above explanation in commit which introduces 
CPUFREQ_POLICY_POWERSAVE/PERFORMANCE

> > --- a/tools/misc/xenpm.c
> > +++ b/tools/misc/xenpm.c
> > @@ -790,9 +790,18 @@ static unsigned int
> > calculate_activity_window(const xc_cppc_para_t *cppc,
> >  /* print out parameters about cpu frequency */  static void
> > print_cpufreq_para(int cpuid, struct xc_get_cpufreq_para *p_cpufreq)
> > {
> > -    bool hwp = strcmp(p_cpufreq->scaling_driver, XEN_HWP_DRIVER_NAME)
> == 0;
> > +    bool cppc_mode = false, hw_auto = false;
> >      int i;
> >
> > +    if ( !strcmp(p_cpufreq->scaling_driver, XEN_HWP_DRIVER_NAME) ||
> > +         !strcmp(p_cpufreq->scaling_driver, XEN_AMD_CPPC_DRIVER_NAME) ||
> > +         !strcmp(p_cpufreq->scaling_driver,
> XEN_AMD_CPPC_EPP_DRIVER_NAME) )
> > +        cppc_mode = true;
> > +
> > +    if ( !strcmp(p_cpufreq->scaling_driver, XEN_HWP_DRIVER_NAME) ||
> > +         !strcmp(p_cpufreq->scaling_driver,
> XEN_AMD_CPPC_EPP_DRIVER_NAME) )
> > +        hw_auto = true;
>
> Please avoid doing the same strcmp()s twice. There are several ways how to, so
> I'm not going to make a particular suggestion.
>

Maybe we shall use switch-case() to replace the same strcmp()s
Since it's not easy to switch-case() string value, I had a draft idea to 
include an new entry in "struct xen_cppc_para",
See:
```
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index fa431fd983..b872f1b66a 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -308,6 +308,10 @@ struct xen_ondemand {

 struct xen_cppc_para {
     /* OUT */
+#define XEN_SYSCTL_CPPC_VENDOR_HWP      1
+#define XEN_SYSCTL_CPPC_VENDOR_AMD      2
+#define XEN_SYSCTL_CPPC_VENDOR_AMD_EPP  3
+    uint8_t vendor;
     /* activity_window supported if set */
 #define XEN_SYSCTL_CPPC_FEAT_ACT_WINDOW  (1 << 0)
     uint32_t features; /* bit flags for features */

```
A new vendor filed in struct xen_cppc_para could help us differ the underlying 
implementation.
Or any better suggestions?

> > @@ -800,7 +809,7 @@ static void print_cpufreq_para(int cpuid, struct
> xc_get_cpufreq_para *p_cpufreq)
> >          printf(" %d", p_cpufreq->affected_cpus[i]);
> >      printf("\n");
> >
> > -    if ( hwp )
> > +    if ( hw_auto )
> >          printf("cpuinfo frequency    : base [%"PRIu32"] max [%"PRIu32"]\n",
> >                 p_cpufreq->cpuinfo_min_freq,
> >                 p_cpufreq->cpuinfo_max_freq);
> > --- a/xen/drivers/acpi/pmstat.c
> > +++ b/xen/drivers/acpi/pmstat.c
> > @@ -201,7 +201,7 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op
> *op)
> >      pmpt = processor_pminfo[op->cpuid];
> >      policy = per_cpu(cpufreq_cpu_policy, op->cpuid);
> >
> > -    if ( !pmpt || !pmpt->perf.states ||
> > +    if ( !pmpt || ((pmpt->init & XEN_PX_INIT) && !pmpt->perf.states)
> > + ||
> >           !policy || !policy->governor )
> >          return -EINVAL;
>
> This looks questionable all on its own. Where is it that ->perf.states 
> allocation is
> being avoided? I first thought it might be patch 06 which is related, but 
> that doesn't
> look to be it. In any event further down from here there is
>

->perf.states is allocated in set_px_pminfo()
It is a px-specific function.

>     for ( i = 0; i < op->u.get_para.freq_num; i++ )
>         data[i] = pmpt->perf.states[i].core_frequency * 1000;
>
> i.e. an access to the array solely based on hypercall input.
>

I'll guard it with pmpt->init & XEN_PX_INIT too

> Both this and ...
>
> > @@ -461,9 +461,10 @@ int do_pm_op(struct xen_sysctl_pm_op *op)
> >      switch ( op->cmd & PM_PARA_CATEGORY_MASK )
> >      {
> >      case CPUFREQ_PARA:
> > -        if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) )
> > +        if ( !(xen_processor_pmbits & (XEN_PROCESSOR_PM_PX |
> > +                                       XEN_PROCESSOR_PM_CPPC)) )
> >              return -ENODEV;
> > -        if ( !pmpt || !(pmpt->init & XEN_PX_INIT) )
> > +        if ( !pmpt || !(pmpt->init & (XEN_PX_INIT | XEN_CPPC_INIT)) )
> >              return -EINVAL;
> >          break;
> >      }
>
> ... this hunk also look as if they would belong (partly?) in maybe patch 03?
> Even more so as per the title this is solely a tool stack (xenpm) change.
>

True, I shall move them to 03, to let this commit being solely a tool stack 
(xenpm) change
> Jan

 


Rackspace

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