[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 06:04:02 +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=nGnCakyqd8UMKZiuJ0iK2GF1Bhi+bRcqVYDKw5ml4zE=; b=DikHha9OmXc5ZjMVc5zML7xxtrEU+DWI87iaVyqHkBUdniEOtnrdZFXki39mSSnlOd0P48LoL696NGwWsuFWOVGMAheWpXHfOZtc2Fx4G2sNVWyVFkYZ/mJlpi0onYQ+M0721gSRxklxGJl1q3Lff/6zd+leyJ/iskyyKilo/usQtQcilTPjCyi3phpxVlyVWJWZ1Hh4O2tgdUG042PanFZrmQRIZQqm690fS7Te78MwhNTqT4mNjjz1kxxSK4a7MjuZJCp7TN3ERty/pS3EdzmsLabywFuNcFAxOGvk07rIYjG1dY5hoLRWY0mZyZKR9Y4W62ieagAN28j67UANag==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P+YLdtqLB4ehAwrMhBdwIZJMXRyXco+/CN00AjT19Ix9ACVHPqrV/KUe2Km9ona5yrFhkfURjldsavhWOgAQBiC3cJ3dFS0MscExfeGPaDT76INdWfbTKrjhJgOuXjQVaj4qQZxCFnj8LulnnWZdaMC1NVnFda5pHrFW4NU9dDzYDtbjcmf8gkqPeGAa1sGjlFibqh2DptW5dyc9bep0N0Lpx6oIBFLO3YW1PdjoeamPMebEc0EN9OVBFWUn+hSuufNUJrJCR5hEgNx8mAIpAY+QatwbhIZ4h8uIKHhbdWkbEzMCHuTtGnAsLyKfARNXV5EEsiyWSi6DzKVtXLW6jg==
  • 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 06:04:17 +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:58:27.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+bQ04KUAgB1EuoA=
  • 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)?
>
> >  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 ...
>

I found that we already have array index check in setup_cpufreq_option(), 
before calling handle_cpufreq_cmdline()
Then maybe there is no need to do it again here

> > +    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®.