Skip to contentSkip to conversation

x86/intel_pstate: add a booting param to select the driver to load

PATCH In review Wei Wang 2 participants 7 messages May 13, 2015 – Jun 4, 2015

lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH v2 7/9 x86/intel_pstate: add a booting param to select the driver to load

By default, the old P-state driver (acpi-freq) is used. Adding "intel_pstate=enable" to the Xen booting param list to enable the use of intel_pstate. However, if intel_pstate is enabled on a machine which does not support the driver (e.g. Nehalem), the old P-state driver will be loaded due to the failure loading of intel_pstate.

---
 xen/arch/x86/acpi/cpufreq/cpufreq.c      |  9 ++++++---
 xen/arch/x86/acpi/cpufreq/intel_pstate.c | 21 +++++++++++++++++++--
 xen/include/asm-x86/acpi.h               |  2 ++
 3 files changed, 27 insertions(+), 5 deletions(-)
xen/arch/x86/acpi/cpufreq/cpufreq.c +6 -3
index fa3678d..f75f356 100644
@@ -650,9 +650,12 @@ static int __init cpufreq_driver_init(void)
     int ret = 0;
 
     if ((cpufreq_controller == FREQCTL_xen) &&
-        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
-        ret = cpufreq_register_driver(&acpi_cpufreq_driver);
-    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) {
+        if (load_intel_pstate)
+            ret = intel_pstate_init();
+        if (!load_intel_pstate)
+            ret = cpufreq_register_driver(&acpi_cpufreq_driver);
+    } else if ((cpufreq_controller == FREQCTL_xen) &&
         (boot_cpu_data.x86_vendor == X86_VENDOR_AMD))
         ret = powernow_register_driver();
 
xen/arch/x86/acpi/cpufreq/intel_pstate.c +19 -2
index 052a0d0..c1a8b11 100644
@@ -766,6 +766,8 @@ static struct cpufreq_driver intel_pstate_driver = {
     .name         = "intel_pstate",
 };
 
+int __initdata load_intel_pstate = 0;
+
 static int intel_pstate_msrs_not_valid(void)
 {
     /* Check that all the msr's we are using are valid. */
@@ -819,10 +821,14 @@ int __init intel_pstate_init(void)
     if (cpuid_ecx(6) & 0x1)
         set_bit(X86_FEATURE_APERFMPERF, &boot_cpu_data.x86_capability);
 
-    id = x86_match_cpu(intel_pstate_cpu_ids);
-    if (!id)
+    if (!load_intel_pstate)
         return -ENODEV;
 
+    id = x86_match_cpu(intel_pstate_cpu_ids);
+    if (!id) {
+        load_intel_pstate = 0;
+        return -ENODEV;
+    }
     cpu_info = (struct cpu_defaults *)id->driver_data;
 
     copy_pid_params(&cpu_info->pid_policy);
@@ -850,3 +856,14 @@ out:
     xfree(all_cpu_data);
     return -ENODEV;
 }
+
+static int __init intel_pstate_setup(char *str)
+{
+    if (!str)
+        return -EINVAL;
+    if (!strcmp(str, "enable"))
+        load_intel_pstate = 1;
+
+    return 0;
+}
+custom_param("intel_pstate", intel_pstate_setup);
xen/include/asm-x86/acpi.h +2 -0
index 505d7e7..1a97545 100644
@@ -32,6 +32,8 @@
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
 
+extern int load_intel_pstate;
+
 extern int intel_pstate_init(void);
 
 /*
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:51, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
@@ -650,9 +650,12 @@ static int __init cpufreq_driver_init(void)
     int ret = 0;

xen/arch/x86/acpi/cpufreq/cpufreq.c static int __init cpufreq_driver_init(void) · line 657

Quoted 10 lines
xen/arch/x86/acpi/cpufreq/cpufreq.c +5 -3
 
     if ((cpufreq_controller == FREQCTL_xen) &&
-        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
-        ret = cpufreq_register_driver(&acpi_cpufreq_driver);
-    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) {
+        if (load_intel_pstate)
+            ret = intel_pstate_init();
+        if (!load_intel_pstate)
+            ret = cpufreq_register_driver(&acpi_cpufreq_driver);

I don't see why you need load_intel_pstate here: Simply call the original function whenever intel_pstate_init() returns an error.

xen/arch/x86/acpi/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstate_driver = { · line 769

Quoted 7 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c +1 -0
@@ -766,6 +766,8 @@ static struct cpufreq_driver intel_pstate_driver = {
     .name         = "intel_pstate",
 };
 
+int __initdata load_intel_pstate = 0;

static bool_t

Quoted 5 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c +1 -0
@@ -850,3 +856,14 @@ out:
     xfree(all_cpu_data);
     return -ENODEV;
 }
+

xen/arch/x86/acpi/cpufreq/intel_pstate.c out: · line 869

Quoted 10 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c +10 -0
+static int __init intel_pstate_setup(char *str)
+{
+    if (!str)
+        return -EINVAL;
+    if (!strcmp(str, "enable"))
+        load_intel_pstate = 1;
+
+    return 0;
+}
+custom_param("intel_pstate", intel_pstate_setup);

This is an ordinary boolean_param().

Jan

#2 lore raw

On 26/05/2015 22:02, Jan Beulich wrote

Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:51, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
xen/arch/x86/acpi/cpufreq/intel_pstate.c +0 -0
@@ -766,6 +766,8 @@ static struct cpufreq_driver intel_pstate_driver = {
     .name         = "intel_pstate",
 };
 
Quoted 3 lines

xen/arch/x86/acpi/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstate_driver = { · line 769

Quoted 1 line
xen/arch/x86/acpi/cpufreq/intel_pstate.c +1 -0
+int __initdata load_intel_pstate = 0;

static bool_t

I think we cannot use "static" here, since load_intel_pstate is also used in cpufreq.c to select which driver to load.

Best,
Wei

#3 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 03.06.15 at 10:07, <[email protected]> wrote:

On 26/05/2015 22:02, Jan Beulich wrote

Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:51, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
xen/arch/x86/acpi/cpufreq/intel_pstate.c +0 -0
@@ -766,6 +766,8 @@ static struct cpufreq_driver intel_pstate_driver = {
     .name         = "intel_pstate",
 };
 
Quoted 6 lines
Quoted 3 lines

xen/arch/x86/acpi/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstate_driver = { · line 769

Quoted 1 line
xen/arch/x86/acpi/cpufreq/intel_pstate.c +1 -0
+int __initdata load_intel_pstate = 0;

static bool_t

I think we cannot use "static" here, since load_intel_pstate is also used in cpufreq.c to select which driver to load.

Iirc I had also requested to deal with that (as it looks pretty hackish right now).

Jan

#4 lore raw

On 03/06/2015 19:51, Jan Beulich wrote

Quoted 12 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 03.06.15 at 10:07, <[email protected]> wrote:

On 26/05/2015 22:02, Jan Beulich wrote

Quoted 6 lines

xen/arch/x86/acpi/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstate_driver =

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:51, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
xen/arch/x86/acpi/cpufreq/intel_pstate.c +0 -0
@@ -766,6 +766,8 @@ static struct cpufreq_driver intel_pstate_driver =

{

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
xen/arch/x86/acpi/cpufreq/intel_pstate.c +0 -0
     .name         = "intel_pstate",
 };
 
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

xen/arch/x86/acpi/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstate_driver = { · line 769

Quoted 1 line
xen/arch/x86/acpi/cpufreq/intel_pstate.c +1 -0
+int __initdata load_intel_pstate = 0;

static bool_t

I think we cannot use "static" here, since load_intel_pstate is also used in cpufreq.c to select which driver to load.

Iirc I had also requested to deal with that (as it looks pretty hackish right now).

I'm not sure about this. Can you please elaborate it - why it looks hackish by doing so? What is your preferred way to do it? Thanks.

The following is your another comment on "load_intel_pstate":

Quoted 15 lines

xen/arch/x86/acpi/cpufreq/cpufreq.c static int __init cpufreq_driver_init(void) · line 657

Quoted 12 lines
xen/arch/x86/acpi/cpufreq/cpufreq.c +5 -3
@@ -650,9 +650,12 @@ static int __init cpufreq_driver_init(void)
     int ret = 0;
 
     if ((cpufreq_controller == FREQCTL_xen) &&
-        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
-        ret = cpufreq_register_driver(&acpi_cpufreq_driver);
-    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) {
+        if (load_intel_pstate)
+            ret = intel_pstate_init();
+        if (!load_intel_pstate)
+            ret = cpufreq_register_driver(&acpi_cpufreq_driver);

I don't see why you need load_intel_pstate here: Simply call the original function whenever intel_pstate_init() returns an error.

I plan to change it to:

	if (load_intel_pstate)
		ret = intel_pstate_init();
	if (ret)
		ret = cpufreq_register_driver(&acpi_cpufreq_driver);

This allows the case that the machine supports the intel_pstate driver but people just prefer to use the old driver for their own reasons.

Best,
Wei

#5 lore raw

On 04/06/2015 09:18, Wei Wang wrote

Quoted 47 lines

On 03/06/2015 19:51, Jan Beulich wrote

Quoted 13 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 03.06.15 at 10:07, <[email protected]> wrote:

On 26/05/2015 22:02, Jan Beulich wrote

Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 13.05.16 at 09:51, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
xen/arch/x86/acpi/cpufreq/intel_pstate.c +0 -0
@@ -766,6 +766,8 @@ static struct cpufreq_driver

intel_pstate_driver =

{

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

.name = "intel_pstate",
};

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+int __initdata load_intel_pstate = 0;

static bool_t

I think we cannot use "static" here, since load_intel_pstate is also used in cpufreq.c to select which driver to load.

Iirc I had also requested to deal with that (as it looks pretty hackish right

now).

I'm not sure about this. Can you please elaborate it - why it looks hackish by doing so?
What is your preferred way to do it? Thanks.

The following is your another comment on "load_intel_pstate":

Quoted 16 lines

xen/arch/x86/acpi/cpufreq/cpufreq.c static int __init cpufreq_driver_init(void) · line 657

Quoted 12 lines
xen/arch/x86/acpi/cpufreq/cpufreq.c +5 -3
@@ -650,9 +650,12 @@ static int __init cpufreq_driver_init(void)
     int ret = 0;
 
     if ((cpufreq_controller == FREQCTL_xen) &&
-        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
-        ret = cpufreq_register_driver(&acpi_cpufreq_driver);
-    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) {
+        if (load_intel_pstate)
+            ret = intel_pstate_init();
+        if (!load_intel_pstate)
+            ret = cpufreq_register_driver(&acpi_cpufreq_driver);

I don't see why you need load_intel_pstate here: Simply call the original function whenever
intel_pstate_init() returns an error.

Quoted 8 lines

I plan to change it to:

	if (load_intel_pstate)
		ret = intel_pstate_init();
	if (ret)
		ret = cpufreq_register_driver(&acpi_cpufreq_driver);

This allows the case that the machine supports the intel_pstate driver but people just prefer to use the old driver for their own reasons.

Missed one thing, it should be like this:

	if (load_intel_pstate)
		ret = intel_pstate_init();
	if (ret || ! load_intel_pstate)
		ret = cpufreq_register_driver(&acpi_cpufreq_driver);

Best,
Wei

#6 lore raw
In reply to Wang, Wei W
Quoted 19 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Wang, Wei W" <[email protected]> 06/04/15 3:15 AM >>>

On 03/06/2015 19:51, Jan Beulich wrote

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 03.06.15 at 10:07, <[email protected]> wrote:
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -0
@@ -650,9 +650,12 @@ static int __init cpufreq_driver_init(void)
     int ret = 0;
 
Quoted 12 lines

xen/arch/x86/acpi/cpufreq/cpufreq.c static int __init cpufreq_driver_init(void) · line 657

Quoted 9 lines
xen/arch/x86/acpi/cpufreq/cpufreq.c +5 -3
     if ((cpufreq_controller == FREQCTL_xen) &&
-        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
-        ret = cpufreq_register_driver(&acpi_cpufreq_driver);
-    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) {
+        if (load_intel_pstate)
+            ret = intel_pstate_init();
+        if (!load_intel_pstate)
+            ret = cpufreq_register_driver(&acpi_cpufreq_driver);

I don't see why you need load_intel_pstate here: Simply call the original function whenever intel_pstate_init() returns an error.

Quoted 8 lines

I plan to change it to:
if (load_intel_pstate)
ret = intel_pstate_init();
if (ret)
ret = cpufreq_register_driver(&acpi_cpufreq_driver);

This allows the case that the machine supports the intel_pstate driver but people just prefer to use the old driver for their own reasons.

But there's no point in using load_intel_pstate here - it should be a variable local to that driver. Simply call the function unconditionally and check the variable first thing inside the function.

Jan