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

RE: [PATCH v4 04/15] xen/cpufreq: refactor cmdline "cpufreq=xxx"


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Andryuk, Jason" <Jason.Andryuk@xxxxxxx>
  • From: "Penny, Zheng" <penny.zheng@xxxxxxx>
  • Date: Thu, 19 Jun 2025 08:00:57 +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=7FEjwGJzYrfEAklclyCSkxTAP/bUHEyPFdkZtY9WdDI=; b=XXveS277N4oY9BqtvC21ZvYskuBcgs3ou4Si/N4EuXsGwhbS92bMNseu9vvChjs0PQzJg4gUrN/4Iz4pTd3V8d4sHeFKSphANsuIa4Q+a+HSifY39slYj0y+TYnMdzRXqH9fJNrPlSbbPBab7BozGLWYP18QY5CyEpc25+TUu/dXQhaLiKVES9dw3/271gdfXF3W+mLZCrzKzs3sch83cbfpvtl6DnTr7ROtVmz6c0Uo/5fIcbee6SyhjQcRJLBKGreRM+RTLfo4MCticEjkpMzTNFO5KXChsQ8ZJvMk7avMB1AX/FiXellMNImlsCtR9RgR4nSd9E+tm3oneYIuvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=taZgPzP7Y9O/tuEIrke3Xk7usHtYChTnc5EZjx/vmWv5FXwpHwV87z1tef7vv4/JmsDW4CUixpcdvXV+pDJSAj+G0mHxXJa1In3R5qZIAOOeO+i9erx88H07aUUndpVkKA/OMqQbgFDUdft6z8qnQIGEy2h5jz7wCAP72Dt4olUO7FZAvwzxbcLmMj6t8lX2OrnXH904kS9HkzUXYXX3OlXSo/KSTS2XO/sRe7wNdZAZeXj0efjZyjUC11+HxwqdlhD+Xr8B2Vc9uCd4dGJjWPK2c/revjQcgPeqayUnosIZ3wLXi4LhmeIkP+5rYRdb/+f8FLubCY95urSyN9hKKA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Huang, Ray" <Ray.Huang@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Thu, 19 Jun 2025 08:01:09 +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-06-19T07:51: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: AQHbrRCkbAdH8T2kS0OlR5huTdSxQbQKgmtQgAADmcA=
  • Thread-topic: [PATCH v4 04/15] xen/cpufreq: refactor cmdline "cpufreq=xxx"

[Public]

> -----Original Message-----
> From: Penny, Zheng
> Sent: Thursday, June 19, 2025 3:52 PM
> To: xen-devel@xxxxxxxxxxxxxxxxxxxx; Jan Beulich <jbeulich@xxxxxxxx>; Andryuk,
> Jason <Jason.Andryuk@xxxxxxx>
> Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Jan Beulich <jbeulich@xxxxxxxx>
> Subject: RE: [PATCH v4 04/15] xen/cpufreq: refactor cmdline "cpufreq=xxx"
>
>
>
> > -----Original Message-----
> > From: Penny, Zheng <penny.zheng@xxxxxxx>
> > Sent: Monday, April 14, 2025 3:41 PM
> > To: xen-devel@xxxxxxxxxxxxxxxxxxxx
> > Cc: Huang, Ray <Ray.Huang@xxxxxxx>; Penny, Zheng
> > <penny.zheng@xxxxxxx>; Jan Beulich <jbeulich@xxxxxxxx>
> > Subject: [PATCH v4 04/15] xen/cpufreq: refactor cmdline "cpufreq=xxx"
> >
> > A helper function handle_cpufreq_cmdline() is introduced to tidy
> > different handling pathes.
> > We also add a new helper cpufreq_opts_contain() to ignore and warn
> > user redundant setting, like "cpufreq=hwp;hwp;xen"
> >
> > Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
> > ---
> > v2 -> v3:
> > - new commit
> > ---
> > v3 -> v4:
> > - add one single helper to do the tidy work
> > - ignore and warn user redundant setting
> > ---
> >  xen/drivers/cpufreq/cpufreq.c | 53
> > +++++++++++++++++++++++++++++------
> >  1 file changed, 45 insertions(+), 8 deletions(-)
> >
> > diff --git a/xen/drivers/cpufreq/cpufreq.c
> > b/xen/drivers/cpufreq/cpufreq.c index
> > e01acc0c2d..79c6444116 100644
> > --- a/xen/drivers/cpufreq/cpufreq.c
> > +++ b/xen/drivers/cpufreq/cpufreq.c
> > @@ -71,6 +71,49 @@ unsigned int __initdata cpufreq_xen_cnt = 1;
> >
> >  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) )
> > +    {
> > +        const char *cpufreq_opts_str[] = { "CPUFREQ_xen", "CPUFREQ_hwp"
> > + };
> > +
> > +        printk(XENLOG_WARNING
> > +               "Duplicate cpufreq driver option: %s",
> > +               cpufreq_opts_str[option - 1]);
> > +        return 0;
> > +    }
> > +
> > +    cpufreq_controller = FREQCTL_xen;
> > +    cpufreq_xen_opts[cpufreq_xen_cnt++] = option;
> > +    switch ( option )
> > +    {
> > +    case CPUFREQ_hwp:
> > +    case CPUFREQ_xen:
> > +        xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
> > +        break;
> > +    default:
> > +        ret = -EINVAL;
>
> I'm thinking since handle_cpufreq_cmdline() is totally internal and has very 
> few
> caller, maybe  ASSERT_UNREACHABLE() is more suitable. Then the function itself
> could become void return.

Sorry, forgot the release build. I'll add assert and stays with non-void return

>
> > +        break;
> > +    }
> > +
> > +    return ret;
> > +}
> > +
> >  static int __init cf_check setup_cpufreq_option(const char *str)  {
> >      const char *arg = strpbrk(str, ",:;"); @@ -114,20 +157,14 @@
> > static int __init cf_check setup_cpufreq_option(const char *str)
> >
> >          if ( choice > 0 || !cmdline_strcmp(str, "xen") )
> >          {
> > -            xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
> > -            cpufreq_controller = FREQCTL_xen;
> > -            cpufreq_xen_opts[cpufreq_xen_cnt++] = CPUFREQ_xen;
> > -            ret = 0;
> > +            ret = handle_cpufreq_cmdline(CPUFREQ_xen);
> >              if ( arg[0] && arg[1] )
> >                  ret = cpufreq_cmdline_parse(arg + 1, end);
> >          }
> >          else if ( IS_ENABLED(CONFIG_INTEL) && choice < 0 &&
> >                    !cmdline_strcmp(str, "hwp") )
> >          {
> > -            xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
> > -            cpufreq_controller = FREQCTL_xen;
> > -            cpufreq_xen_opts[cpufreq_xen_cnt++] = CPUFREQ_hwp;
> > -            ret = 0;
> > +            ret = handle_cpufreq_cmdline(CPUFREQ_hwp);
> >              if ( arg[0] && arg[1] )
> >                  ret = hwp_cmdline_parse(arg + 1, end);
> >          }
> > --
> > 2.34.1




 


Rackspace

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