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

RE: [PATCH v7 13/13] xen/cpufreq: Adapt SET/GET_CPUFREQ_CPPC xen_sysctl_pm_op for amd-cppc driver


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Thu, 28 Aug 2025 04:06:32 +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=fSlLeeYDhJHR/RwvS2xUqV7ZvJzVthNx3e4DV2yY0f0=; b=N5opMK+rk+19qoyRU1kqNYVWZfpglKvq47eoWrZ7ReQzKoxBA9NBgk5dAtizm9tkMTUJHsROb7/rPcMgOobiuA2BU83OvvuB9fuVZGugg9kPc/cfvEl8YEyjMmZk2oMFYqH67PYqpiZMWVemkyUdfxQdnmB6WP5Mleg2rSre31oCfyWfLcLDPxneb9bIsMAA0s6vw1vUUxht4EgmlPE5B6X2OGBExyLkjTU6zR5bLgHKjsoeFSUiF2FwAjnE32nXAkHHWtKDM7MZOZuGnka2AbcLBtMaQUaVogwSFh+nbvj/tAjP+9G9fNsYExZAVu/CcWuVB+oSgh+WkW0Nw2bwGw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cnwe7ljv+zReZlxkCUyvJOPdo86fO/+q3GIDM+yTMixU5bVNZ0BJbAT5Tl8bYtShq1+MUWFp+9R/fi8eNhJAvK55cfjR5vbliKu8qCHCWGPhJe/G7HpAWNd/Q02RSSMX/NFM8vgz3m8QPHbg6wRUJaX3f2ZsyuNtQ8I0z5StPnGwipBYn2WSJIL7BxunIcyMNZWxQe2QI+kzjMvTDtgY/c2SH+FYsjajyFVPrZci7CWiJI2mvzncctyvy5xOzNVwqgG1aKliD9lyZWdqbMukwleoQlrhaW7gQABO+Rp9hCJXNTBmMLFvgOJZyJOYkL8BKPKyp/pOXhzd0IHUCQ1c5w==
  • 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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Orzel, Michal" <Michal.Orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 28 Aug 2025 04:06:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_labels: MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Enabled=True;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_SetDate=2025-08-27T06:36:58.0000000Z;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Name=Open Source;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_ContentBits=3;MSIP_Label_f265efc6-e181-49d6-80f4-fae95cf838a0_Method=Privileged
  • Thread-index: AQHcE1L0WO8OIJho60KGV8JFR/QspLRzjMCAgAJSvzA=
  • Thread-topic: [PATCH v7 13/13] xen/cpufreq: Adapt SET/GET_CPUFREQ_CPPC xen_sysctl_pm_op for amd-cppc driver

[Public]

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Tuesday, August 26, 2025 12:03 AM
> To: Penny, Zheng <penny.zheng@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Anthony PERARD
> <anthony.perard@xxxxxxxxxx>; Andrew Cooper <andrew.cooper3@xxxxxxxxxx>;
> Orzel, Michal <Michal.Orzel@xxxxxxx>; Julien Grall <julien@xxxxxxx>; Roger
> Pau Monné <roger.pau@xxxxxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>;
> xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v7 13/13] xen/cpufreq: Adapt SET/GET_CPUFREQ_CPPC
> xen_sysctl_pm_op for amd-cppc driver
>
> On 22.08.2025 12:52, Penny Zheng wrote:
> > --- a/xen/arch/x86/acpi/cpufreq/amd-cppc.c
> > +++ b/xen/arch/x86/acpi/cpufreq/amd-cppc.c
> > +    /* Only allow values if params bit is set. */
> > +    if ( (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_DESIRED) &&
> > +          set_cppc->desired) ||
> > +         (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MINIMUM) &&
> > +          set_cppc->minimum) ||
> > +         (!(set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM) &&
> > +          set_cppc->maximum) ||
> > +         (!(set_cppc->set_params &
> XEN_SYSCTL_CPPC_SET_ENERGY_PERF) &&
> > +          set_cppc->energy_perf) )
> > +        return -EINVAL;
>
> ... all the errors checked here are to be ignored when no flag is set at all?
>

Yes, values are only meaningful when according flag is properly set, which has 
been described in the comment for "struct xen_set_cppc_para"

> > +    /*
> > +     * Validate all parameters
> > +     * Maximum performance may be set to any performance value in the range
> > +     * [Nonlinear Lowest Performance, Highest Performance], inclusive but
> must
> > +     * be set to a value that is larger than or equal to minimum 
> > Performance.
> > +     */
> > +    if ( (set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM) &&
> > +         (set_cppc->maximum > data->caps.highest_perf ||
> > +          set_cppc->maximum <
> > +                        (set_cppc->set_params &
> XEN_SYSCTL_CPPC_SET_MINIMUM
> > +                         ? set_cppc->minimum
> > +                         : data->req.min_perf)) )
>
> Too deep indentation (more of this throughout the function), and seeing ...

Maybe four indention is more proper
```
        if ( (set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MAXIMUM) &&
             (set_cppc->maximum > data->caps.highest_perf ||
              (set_cppc->maximum <
                          (set_cppc->set_params & XEN_SYSCTL_CPPC_SET_MINIMUM
                    ? set_cppc->minimum
                    : data->req.min_perf))) )
```

> > +    case XEN_SYSCTL_CPPC_SET_PRESET_NONE:
> > +        if ( active_mode )
> > +            policy->policy = CPUFREQ_POLICY_UNKNOWN;
> > +        break;
> > +
> > +    default:
> > +        return -EINVAL;
> > +    }
>
> Much of this looks very similar to what patch 09 introduces in
> amd_cppc_epp_set_policy(). Is it not possible to reduce the redundancy?
>

I'll add a new helper to amd_cppc_prepare_policy() to extract common

> > --- a/xen/include/public/sysctl.h
> > +++ b/xen/include/public/sysctl.h
> > @@ -336,8 +336,14 @@ struct xen_ondemand {
> >      uint32_t up_threshold;
> >  };
> >
> > +#define CPUFREQ_POLICY_UNKNOWN      0
> > +#define CPUFREQ_POLICY_POWERSAVE    1
> > +#define CPUFREQ_POLICY_PERFORMANCE  2
> > +#define CPUFREQ_POLICY_ONDEMAND     3
>
> Without XEN_ prefixes they shouldn't appear in a public header. But do we
> need ...
>
> >  struct xen_get_cppc_para {
> >      /* OUT */
> > +    uint32_t policy; /* CPUFREQ_POLICY_xxx */
>
> ... the new field at all? Can't you synthesize the kind-of-governor into 
> struct
> xen_get_cpufreq_para's respective field? You invoke both sub-ops from xenpm
> now anyway ...
>

Maybe I could borrow governor field to indicate policy info, like the following 
in print_cpufreq_para(), then we don't need to add the new filed "policy"
```
+    /* Translate governor info to policy info in CPPC active mode */
+    if ( is_cppc_active )
+    {
+        if ( !strncmp(p_cpufreq->u.s.scaling_governor,
+                      "ondemand", CPUFREQ_NAME_LEN) )
+            printf("cppc policy           : ondemand\n");
+        else if ( !strncmp(p_cpufreq->u.s.scaling_governor,
+                           "performance", CPUFREQ_NAME_LEN) )
+            printf("cppc policy           : performance\n");
+
+        else if ( !strncmp(p_cpufreq->u.s.scaling_governor,
+                           "powersave", CPUFREQ_NAME_LEN) )
+            printf("cppc policy           : powersave\n");
+        else
+            printf("cppc policy           : unknown\n");
+    }
+
```

> Jan

 


Rackspace

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