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

RE: [PATCH v6 05/19] xen/cpufreq: refactor cmdline "cpufreq=xxx"


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Mon, 4 Aug 2025 05:47:50 +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=ZBK2kaKkvA0SGmUyLNgD1ovYSGR86Ql41qh9k1MT3Yw=; b=SO4CsSRSUBZcTTUwcV/zt/EzcLrJdwgjPVuscxnyD/I4cSrZUhSLdgLJXCcWfoNgPM8D9dS3X4C5yHT7/mF4p8kQkfvuDHfKtYGGAlIUnEJnQcseZ+QbAODiTQEIEdE4Nc3vDLz4/8dMS23cS4saGoXyCvcNgDYyj+FY70zwqO9inyc/J0jJPg96nKUeXQKt7pdYc4EHRfuIngCkUvBrLPQZj1w6RaEqdGC0ZUC284TgXSpVyFrKmd2PulQa/Vok1r3NX7Kq3zK4C4aDCFatqeD07/Pi1/IbCd0ONHFvSU9lYpmTUxzBdPQwRG4AodD66JmHYcC9PiiU8g4e949+Ew==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qPoxAldojGdiH0xBUrYHOx7Cof8F+VURFAcfPjy8rYL6frSiWcUfIQB5f/Hsts17bZiPnBGGlgrGNmBHw3FK10E43XFclpHcXOwpOdsHjbyi+5Wo0/FMtdkVh5IRCdxf4OUUlNb0XY7vVa/oNbnOISUSDd6IXeaxbj0Yt4AleuOahM7FS2vlwqfvrAPik4ygGJI+b0zXk6bBnK5VX2uaxLp+qIv/ZMzTr+VdBqUaS1r+s4AbxOw8om11QSPfmF4AOQwAad42y/5F+zF/eiQff9M2KhXqCVqouhNBaf1pCwVaB+rH61Ys9cV3TCimqiauA3MGu9YuoG6X/wcpfmdKpQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 04 Aug 2025 05:48:20 +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-04T05:35:01.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: AQHb8hcZyJcOgUanrEKBu4lvlAPx+bQ04KUAgB0+LSA=
  • Thread-topic: [PATCH v6 05/19] xen/cpufreq: refactor cmdline "cpufreq=xxx"

[Public]

> -----Original Message-----
> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Wednesday, July 16, 2025 11:01 PM
> To: Penny, Zheng <penny.zheng@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH v6 05/19] xen/cpufreq: refactor cmdline "cpufreq=xxx"
>
> On 11.07.2025 05:50, Penny Zheng wrote:
> > --- a/xen/drivers/cpufreq/cpufreq.c
> > +++ b/xen/drivers/cpufreq/cpufreq.c
> > @@ -64,12 +64,53 @@ LIST_HEAD_READ_MOSTLY(cpufreq_governor_list);
> >  /* set xen as default cpufreq */
> >  enum cpufreq_controller cpufreq_controller = FREQCTL_xen;
> >
> > -enum cpufreq_xen_opt __initdata cpufreq_xen_opts[2] = { CPUFREQ_xen,
> > -                                                        CPUFREQ_none };
> > +enum cpufreq_xen_opt __initdata cpufreq_xen_opts[NR_CPUFREQ_OPTS] = {
> > +    CPUFREQ_xen,
> > +    CPUFREQ_none
> > +};
> >  unsigned int __initdata cpufreq_xen_cnt = 1;
>
> Given this, isn't the array index 1 initializer quite pointless above? Or 
> else, if you
> really mean to explicitly fill all slots with CPUFREQ_none (despite that 
> deliberately
> having numeric value 0), why not
> "[1 ... NR_CPUFREQ_OPTS - 1] = CPUFREQ_none" (or using ARRAY_SIZE(), as
> per below)?
>

The cpufreq_xen_cnt initialized as 1 is to have default  CPUFREQ_xen value when 
there is no "cpufreq=xxx" cmdline option
I suppose you are pointing out that the macro NR_CPUFREQ_OPTS is pointless, as 
we could use ARRAY_SIZE().

> >  static int __init cpufreq_cmdline_parse(const char *s, const char
> > *e);
> >
> > +static bool __init cpufreq_opts_contain(enum cpufreq_xen_opt option)
> > +{
> > +    unsigned int count = cpufreq_xen_cnt;
> > +
> > +    while ( count-- )
> > +    {
> > +        if ( cpufreq_xen_opts[count] == option )
> > +            return true;
> > +    }
> > +
> > +    return false;
> > +}
> > +
> > +static int __init handle_cpufreq_cmdline(enum cpufreq_xen_opt option)
> > +{
> > +    int ret = 0;
> > +
> > +    if ( cpufreq_opts_contain(option) )
> > +        return 0;
> > +
> > +    cpufreq_controller = FREQCTL_xen;
> > +    ASSERT(cpufreq_xen_cnt < NR_CPUFREQ_OPTS);
>
> This would better use ARRAY_SIZE(), at which point NR_CPUFREQ_OPTS can go
> away again. What's worse, though, is that on release builds ...
>

Understood, will use ARRAY_SIZE(), and will use if() to error out

> > +    cpufreq_xen_opts[cpufreq_xen_cnt++] = option;
>
> ... you then still overrun this array if something's wrong in this regard.
>
> Jan

 


Rackspace

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