Skip to contentSkip to conversation

cpufreq: allow ordinary boolean options to be passed on the command line

PATCH In review Jan Beulich 2 participants 4 messages Oct 30, 2015 – Nov 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: allow ordinary boolean options to be passed on the command line

I was quite surprised to find "cpufreq=off" not doing what one would expect it to do. Fix this.

docs/misc/xen-command-line.markdown +3 -2
@@ -391,11 +391,12 @@ If set, force use of the performance cou
 available support.
 
 ### cpufreq
-> `= dom0-kernel | none | xen[,[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]`
+> `= none | {{ <boolean> | xen } [:[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]} | dom0-kernel`
 
 > Default: `xen`
 
-Indicate where the responsibility for driving power states lies.
+Indicate where the responsibility for driving power states lies.  Note that the
+choice of `dom0-kernel` is deprecated and not supported by all Dom0 kernels.
 
 * Default governor policy is ondemand.
 * `<maxfreq>` and `<minfreq>` are integers which represent max and min processor frequencies
xen/drivers/cpufreq/cpufreq.c +13 -7
@@ -64,9 +64,14 @@ enum cpufreq_controller cpufreq_controll
 
 static void __init setup_cpufreq_option(char *str)
 {
-    char *arg;
+    char *arg = strpbrk(str, ",:");
+    int choice;
 
-    if ( !strcmp(str, "dom0-kernel") )
+    if ( arg )
+        *arg++ = '\0';
+    choice = parse_bool(str);
+
+    if ( choice < 0 && !strcmp(str, "dom0-kernel") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_dom0_kernel;
@@ -74,19 +79,20 @@ static void __init setup_cpufreq_option(
         return;
     }
 
-    if ( !strcmp(str, "none") )
+    if ( choice == 0 || !strcmp(str, "none") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_none;
         return;
     }
 
-    if ( (arg = strpbrk(str, ",:")) != NULL )
-        *arg++ = '\0';
-
-    if ( !strcmp(str, "xen") )
+    if ( choice > 0 || !strcmp(str, "xen") )
+    {
+        xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
+        cpufreq_controller = FREQCTL_xen;
         if ( arg && *arg )
             cpufreq_cmdline_parse(arg);
+    }
 }
 custom_param("cpufreq", setup_cpufreq_option);
 

cpufreq: allow ordinary boolean options to be passed on the command line

I was quite surprised to find "cpufreq=off" not doing what one would expect it to do. Fix this.

docs/misc/xen-command-line.markdown +3 -2
@@ -391,11 +391,12 @@ If set, force use of the performance cou
 available support.
 
 ### cpufreq
-> `= dom0-kernel | none | xen[,[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]`
+> `= none | {{ <boolean> | xen } [:[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]} | dom0-kernel`
 
 > Default: `xen`
 
-Indicate where the responsibility for driving power states lies.
+Indicate where the responsibility for driving power states lies.  Note that the
+choice of `dom0-kernel` is deprecated and not supported by all Dom0 kernels.
 
 * Default governor policy is ondemand.
 * `<maxfreq>` and `<minfreq>` are integers which represent max and min processor frequencies
xen/drivers/cpufreq/cpufreq.c +13 -7
@@ -64,9 +64,14 @@ enum cpufreq_controller cpufreq_controll
 
 static void __init setup_cpufreq_option(char *str)
 {
-    char *arg;
+    char *arg = strpbrk(str, ",:");
+    int choice;
 
-    if ( !strcmp(str, "dom0-kernel") )
+    if ( arg )
+        *arg++ = '\0';
+    choice = parse_bool(str);
+
+    if ( choice < 0 && !strcmp(str, "dom0-kernel") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_dom0_kernel;
@@ -74,19 +79,20 @@ static void __init setup_cpufreq_option(
         return;
     }
 
-    if ( !strcmp(str, "none") )
+    if ( choice == 0 || !strcmp(str, "none") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_none;
         return;
     }
 
-    if ( (arg = strpbrk(str, ",:")) != NULL )
-        *arg++ = '\0';
-
-    if ( !strcmp(str, "xen") )
+    if ( choice > 0 || !strcmp(str, "xen") )
+    {
+        xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
+        cpufreq_controller = FREQCTL_xen;
         if ( arg && *arg )
             cpufreq_cmdline_parse(arg);
+    }
 }
 custom_param("cpufreq", setup_cpufreq_option);
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw

docs/misc/xen-command-line.markdown If set, force use of the performance cou · line 394

Quoted 13 lines · Jan Beulich

I was quite surprised to find "cpufreq=off" not doing what one would expect it to do. Fix this.

docs/misc/xen-command-line.markdown +1 -1
@@ -391,11 +391,12 @@ If set, force use of the performance cou
 available support.
 
 ### cpufreq
-> `= dom0-kernel | none | xen[,[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]`
+> `= none | {{ <boolean> | xen } [:[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]} | dom0-kernel`

If I am reading the parsing correctly below, the insertion if ':' is to match the previous behaviour? (or have I missed something?)

~Andrew

Quoted 59 lines
docs/misc/xen-command-line.markdown +2 -1
 > Default: `xen`
 
-Indicate where the responsibility for driving power states lies.
+Indicate where the responsibility for driving power states lies.  Note that the
+choice of `dom0-kernel` is deprecated and not supported by all Dom0 kernels.
 
 * Default governor policy is ondemand.
 * `<maxfreq>` and `<minfreq>` are integers which represent max and min processor frequencies
xen/drivers/cpufreq/cpufreq.c +13 -7
@@ -64,9 +64,14 @@ enum cpufreq_controller cpufreq_controll
 
 static void __init setup_cpufreq_option(char *str)
 {
-    char *arg;
+    char *arg = strpbrk(str, ",:");
+    int choice;
 
-    if ( !strcmp(str, "dom0-kernel") )
+    if ( arg )
+        *arg++ = '\0';
+    choice = parse_bool(str);
+
+    if ( choice < 0 && !strcmp(str, "dom0-kernel") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_dom0_kernel;
@@ -74,19 +79,20 @@ static void __init setup_cpufreq_option(
         return;
     }
 
-    if ( !strcmp(str, "none") )
+    if ( choice == 0 || !strcmp(str, "none") )
     {
         xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
         cpufreq_controller = FREQCTL_none;
         return;
     }
 
-    if ( (arg = strpbrk(str, ",:")) != NULL )
-        *arg++ = '\0';
-
-    if ( !strcmp(str, "xen") )
+    if ( choice > 0 || !strcmp(str, "xen") )
+    {
+        xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
+        cpufreq_controller = FREQCTL_xen;
         if ( arg && *arg )
             cpufreq_cmdline_parse(arg);
+    }
 }
 custom_param("cpufreq", setup_cpufreq_option);
 
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 30.10.15 at 20:22, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich

I was quite surprised to find "cpufreq=off" not doing what one would expect it to do. Fix this.

docs/misc/xen-command-line.markdown +0 -0
@@ -391,11 +391,12 @@ If set, force use of the performance cou
 available support.
 
Quoted 6 lines

docs/misc/xen-command-line.markdown If set, force use of the performance cou · line 394

Quoted 3 lines
docs/misc/xen-command-line.markdown +1 -1
 ### cpufreq
-> `= dom0-kernel | none | xen[,[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]`
+> `= none | {{ <boolean> | xen } [:[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]} | dom0-kernel`

If I am reading the parsing correctly below, the insertion if ':' is to match the previous behaviour? (or have I missed something?)

We've always supported , and : there. I do think that documenting comma here is bad (since it's also used as the separator between sub-options), and hence I've taken the opportunity to make this match other command line options (where we generally use colon for separation of main and sub-options).

Jan

Reviewed-by
#3 lore raw
Quoted 17 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 30.10.15 at 20:22, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich

I was quite surprised to find "cpufreq=off" not doing what one would expect it to do. Fix this.

docs/misc/xen-command-line.markdown +0 -0
@@ -391,11 +391,12 @@ If set, force use of the performance cou
 available support.
 
Quoted 5 lines

docs/misc/xen-command-line.markdown If set, force use of the performance cou · line 394

Quoted 3 lines
docs/misc/xen-command-line.markdown +1 -1
 ### cpufreq
-> `= dom0-kernel | none | xen[,[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]`
+> `= none | {{ <boolean> | xen } [:[powersave|performance|ondemand|userspace][,<maxfreq>][,[<minfreq>][,[verbose]]]]} | dom0-kernel`

If I am reading the parsing correctly below, the insertion if ':' is to match the previous behaviour? (or have I missed something?)

Quoted 5 lines

We've always supported , and : there. I do think that documenting comma here is bad (since it's also used as the separator between sub-options), and hence I've taken the opportunity to make this match other command line options (where we generally use colon for separation of main and sub-options).

Agreed.