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

RE: [PATCH v6 11/19] xen/x86: introduce "cpufreq=amd-cppc" xen cmdline and amd-cppc driver


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Mon, 4 Aug 2025 08:09:44 +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=EONlCrXEu+vl1MizfSkbUN73vCDvFetjTYiRA8ZlA5w=; b=CCgG1CiTuGW2FZ+DWVnWnY/nRKGb5zL80+W+Q4IB6Ahz+48+cd9G3BHFBmQ08ofWhuBzfddEtSj5DXEZqbLi5BxPgZF1pG2iwdKBceQbBLq1QHIY4+dLnRWtVFfBajNdKpmMPsr3YdQvmQGMq6YPvPCDp/RAQMvd+BrHzI7UqNMzMP/NoGqpxL3yUkFwkoilTGFSplddnVytTs7Bt3mNAGn+y9XL0uj3FwlOgdgSO5oeRX6YHL9np2ygw3dsHTzXCgKIq0b9jJq9/G2hCghogimzCExNwVJKahldc1qnDVwJVcE0himOflEFt9M81zkrinsiRLN1czUCARc2zsQk8w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QwC05vCN1asvQ91pqabdpS4EU7i6nJhr6DWuDW0tW1hRBJleU4WClPsofxkWZeM43n53IcYV3nzvE4S81F8/7n/fky35xmy1Gd0YnV3Cq5Bab/xDS9LRAGXGWMtJn0bFsRGuCNXt1LvOuCDbwzqlXzhp5BwMgi6ufrFYuHxbfa6saphJ0iyUK90aAxJt4wHjr8angzh6XAPr/IVU1N5ljZJerefvPWGOqfa+TCPSQL6EYc/A6KZycepWlj7w2war8PMfCW5ps56ncptfIj1/qQgmVMwc2f/V5+AMXiHXUtl1Fo9QkgkImOs/exf8fC2SKPSf7G7ll2qnBd+Wfj+Pfw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@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: Mon, 04 Aug 2025 08:10:00 +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-04T08:09:36.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: AQHb8hcjpcuBQZ3yA0mXIz4rkVtX0bQ08RmAgB1Oq3A=
  • Thread-topic: [PATCH v6 11/19] xen/x86: introduce "cpufreq=amd-cppc" xen cmdline and amd-cppc driver

[Public]

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Thursday, July 17, 2025 12:00 AM
> To: Penny, Zheng <penny.zheng@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Andrew Cooper
> <andrew.cooper3@xxxxxxxxxx>; Anthony PERARD <anthony.perard@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 v6 11/19] xen/x86: introduce "cpufreq=amd-cppc" xen 
> cmdline
> and amd-cppc driver
>
> On 11.07.2025 05:50, Penny Zheng wrote:
> > --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
> > +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
> > @@ -128,12 +128,14 @@ static int __init cf_check
> > cpufreq_driver_init(void)
> >
> >      if ( cpufreq_controller == FREQCTL_xen )
> >      {
> > +        unsigned int i = 0;
>
> Pointless initializer; both for() loops set i to 0. But also see further down.
>
> > @@ -157,9 +164,70 @@ static int __init cf_check
> > cpufreq_driver_init(void)
> >
> >          case X86_VENDOR_AMD:
> >          case X86_VENDOR_HYGON:
> > -            ret = IS_ENABLED(CONFIG_AMD) ? powernow_register_driver() : -
> ENODEV;
> > +            if ( !IS_ENABLED(CONFIG_AMD) )
> > +            {
> > +                ret = -ENODEV;
> > +                break;
> > +            }
> > +            ret = -ENOENT;
>
> The code structure is sufficiently different from the Intel counterpart for 
> this to
> perhaps better move ...
>
> > +            for ( i = 0; i < cpufreq_xen_cnt; i++ )
> > +            {
> > +                switch ( cpufreq_xen_opts[i] )
> > +                {
> > +                case CPUFREQ_xen:
> > +                    ret = powernow_register_driver();
> > +                    break;
> > +
> > +                case CPUFREQ_amd_cppc:
> > +                    ret = amd_cppc_register_driver();
> > +                    break;
> > +
> > +                case CPUFREQ_none:
> > +                    ret = 0;
> > +                    break;
> > +
> > +                default:
> > +                    printk(XENLOG_WARNING
> > +                           "Unsupported cpufreq driver for vendor AMD or 
> > Hygon\n");
> > +                    break;
>
> ... here.
>

Are we suggesting moving
"
        if ( !IS_ENABLED(CONFIG_AMD) )
        {
                ret = -ENODEV;
                break;
        }
" here? In which case, When CONFIG_AMD=n and users doesn't provide 
"cpufreq=xxx", we will have cpufreq_xen_cnt initialized as 1 and 
cpufreq_xen_opts[0] = CPUFREQ_xen. powernow_register_driver() hence gets 
invoked. The thing is that we don't have stub for it and it is compiled under 
CONFIG_AMD
I suggest to change to use #ifdef CONFIG_AMD code wrapping

> > +                }
> > +
> > +                if ( !ret || ret == -EBUSY )
> > +                    break;
> > +            }
> > +
> >              break;
> >          }
> > +
> > +        /*
> > +         * After successful cpufreq driver registeration,
> XEN_PROCESSOR_PM_CPPC
> > +         * and XEN_PROCESSOR_PM_PX shall become exclusive flags.
> > +         */
> > +        if ( !ret )
> > +        {
> > +            ASSERT(i < cpufreq_xen_cnt);
> > +            switch ( cpufreq_xen_opts[i] )
>
> Hmm, this is using the the initializer of i that I commented on. I think 
> there's
> another default: case missing, where you simply "return 0" (to retain prior 
> behavior).
> But again see also yet further down.
>
>
> > +            /*
> > +             * No cpufreq driver gets registered, clear both
> > +             * XEN_PROCESSOR_PM_CPPC and XEN_PROCESSOR_PM_PX
> > +             */
> > +             xen_processor_pmbits &= ~(XEN_PROCESSOR_PM_CPPC |
> > +                                       XEN_PROCESSOR_PM_PX);
>
> Yet more hmm - this path you want to get through for the case mentioned above.
> But only this code; specifically not the "switch ( cpufreq_xen_opts[i] )", 
> which really
> is "switch ( cpufreq_xen_opts[0] )" in that case, and that's pretty clearly 
> wrong to
> evaluate in then.
>

Correct me if I understand you wrongly:
The above "case missing" , are we talking about is entering "case CPUFREQ_none" 
?
IMO, it may never be entered. If users doesn't provide "cpufreq=xxx", we will 
have cpufreq_xen_cnt initialized as 1 and cpufreq_xen_opts[0] = CPUFREQ_xen. 
That is, we will have px states as default driver. Even if we have failed 
px-driver initialization, with cpufreq_xen_cnt limited to 1, we will not enter 
CPUFREQ_none.
CPUFREQ_none only could be set when users explicitly set 
"cpufreq=disabled/none/0", but in which case, cpufreq_controller will be set 
with FREQCTL_none. And the whole cpufreq_driver_init() is under " 
cpufreq_controller == FREQCTL_xen " condition
Or "case missing" is referring entering default case? In which case, we will 
have -ENOENT errno. As we have ret=-ENOENT in the very beginning

> Jan

 


Rackspace

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