Skip to contentSkip to conversation

Revert "cpuidle: Make drivers initialize polling state"

PATCH In review Ville Syrjala 3 participants 12 messages Jan 22, 2018 – Feb 12, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "cpuidle: Make drivers initialize polling state"

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

Cc Rafael J. Wysocki <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Daniel Lezcano <[email protected]>
---
 drivers/acpi/processor_idle.c | 9 +--------
 drivers/cpuidle/driver.c      | 2 ++
 drivers/cpuidle/poll_state.c  | 3 +--
 drivers/idle/intel_idle.c     | 1 -
 include/linux/cpuidle.h       | 4 ++--
 5 files changed, 6 insertions(+), 13 deletions(-)
drivers/acpi/processor_idle.c +1 -8
index d50a7b6ccddd..cb1c7634e2ca 100644
@@ -842,7 +842,7 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
 
 static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 {
-	int i, count;
+	int i, count = ACPI_IDLE_STATE_START;
 	struct acpi_processor_cx *cx;
 	struct cpuidle_state *state;
 	struct cpuidle_driver *drv = &acpi_idle_driver;
@@ -850,13 +850,6 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
 	if (max_cstate == 0)
 		max_cstate = 1;
 
-	if (IS_ENABLED(CONFIG_ARCH_HAS_CPU_RELAX)) {
-		cpuidle_poll_state_init(drv);
-		count = 1;
-	} else {
-		count = 0;
-	}
-
 	for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
 		cx = &pr->power.states[i];
 
drivers/cpuidle/driver.c +2 -0
index dc32f34e68d9..6f694c86f3fa 100644
@@ -216,6 +216,8 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
 		on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer,
 				 (void *)1, 1);
 
+	poll_idle_init(drv);
+
 	return 0;
 }
 
drivers/cpuidle/poll_state.c +1 -2
index 7416b16287de..0db4f7273952 100644
@@ -21,7 +21,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
 	return index;
 }
 
-void cpuidle_poll_state_init(struct cpuidle_driver *drv)
+void poll_idle_init(struct cpuidle_driver *drv)
 {
 	struct cpuidle_state *state = &drv->states[0];
 
@@ -34,4 +34,3 @@ void cpuidle_poll_state_init(struct cpuidle_driver *drv)
 	state->disabled = false;
 	state->flags = CPUIDLE_FLAG_POLLING;
 }
-EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);
drivers/idle/intel_idle.c +0 -1
index b2ccce5fb071..6d8a4b87e4d5 100644
@@ -1342,7 +1342,6 @@ static void __init intel_idle_cpuidle_driver_init(void)
 
 	intel_idle_state_table_update();
 
-	cpuidle_poll_state_init(drv);
 	drv->state_count = 1;
 
 	for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
include/linux/cpuidle.h +2 -2
index 8f7788d23b57..bc9f2603fe10 100644
@@ -226,9 +226,9 @@ static inline void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev,
 #endif
 
 #ifdef CONFIG_ARCH_HAS_CPU_RELAX
-void cpuidle_poll_state_init(struct cpuidle_driver *drv);
+void poll_idle_init(struct cpuidle_driver *drv);
 #else
-static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {}
+static void poll_idle_init(struct cpuidle_driver *drv) {}
 #endif
 
 /******************************
Signature · 1 line
2.13.6
#1 lore raw
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

And if you don't do CONFIG_ACPI=n, does it still oops?

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

Thanks,
Rafael

#2 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

Quoted 6 lines

And if you don't do CONFIG_ACPI=n, does it still oops?

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

What's there in /sys/devices/system/cpu/cpuidle/current_driver on your system with the problematic commit reverted?

#3 lore raw
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Rafael J. Wysocki
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

And if you don't do CONFIG_ACPI=n, does it still oops?

Don't think I actually tried that. I can give it a whirl tonight.

I think this machine should actually have ACPI, but it inherited the .config from a P2 machine that did not. Apparently I was too lazy to change .config when I swapped in the "new" machine.

Quoted 8 lines
Quoted 5 lines

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

What's there in /sys/devices/system/cpu/cpuidle/current_driver on your system with the problematic commit reverted?

# cat /sys/devices/system/cpu/cpuidle/current_driver
apm_idle
Signature · 2 lines
Ville Syrjälä
Intel OTC
#4 lore raw
Quoted 11 lines · CET Ville Syrjälä
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

And if you don't do CONFIG_ACPI=n, does it still oops?

Don't think I actually tried that. I can give it a whirl tonight.

I think this machine should actually have ACPI, but it inherited the .config from a P2 machine that did not. Apparently I was too lazy to change .config when I swapped in the "new" machine.

I guess it would work, but never mind.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

What's there in /sys/devices/system/cpu/cpuidle/current_driver on your system with the problematic commit reverted?

# cat /sys/devices/system/cpu/cpuidle/current_driver
apm_idle

That is the key bit: I overlooked this little fellow.

Does the below (untested here) help?

---
 arch/x86/kernel/apm_32.c |    1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/apm_32.c +1 -0
Index: linux-pm/arch/x86/kernel/apm_32.c
===================================================================
@@ -2389,6 +2389,7 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
+		cpuidle_poll_state_init(&apm_idle_driver);
 		if (!cpuidle_register_driver(&apm_idle_driver))
 			if (cpuidle_register_device(&apm_cpuidle_device))
 				cpuidle_unregister_driver(&apm_idle_driver);
author Tested-by
#5 lore raw
Quoted 47 lines · Rafael J. Wysocki
Quoted 11 lines · CET Ville Syrjälä
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

And if you don't do CONFIG_ACPI=n, does it still oops?

Don't think I actually tried that. I can give it a whirl tonight.

I think this machine should actually have ACPI, but it inherited the .config from a P2 machine that did not. Apparently I was too lazy to change .config when I swapped in the "new" machine.

I guess it would work, but never mind.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

What's there in /sys/devices/system/cpu/cpuidle/current_driver on your system with the problematic commit reverted?

# cat /sys/devices/system/cpu/cpuidle/current_driver
apm_idle

That is the key bit: I overlooked this little fellow.

Does the below (untested here) help?

---
 arch/x86/kernel/apm_32.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-pm/arch/x86/kernel/apm_32.c
===================================================================

arch/x86/kernel/apm_32.c static int __init apm_init(void) · line 2395

Quoted 7 lines
arch/x86/kernel/apm_32.c +1 -0
@@ -2389,6 +2389,7 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
+		cpuidle_poll_state_init(&apm_idle_driver);
 		if (!cpuidle_register_driver(&apm_idle_driver))
 			if (cpuidle_register_device(&apm_cpuidle_device))
 				cpuidle_unregister_driver(&apm_idle_driver);

Yep, this works. Thanks.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#6 lore raw
Quoted 58 lines · CET Ville Syrjälä
Quoted 47 lines · Rafael J. Wysocki
Quoted 11 lines · CET Ville Syrjälä
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Ville Syrjala

From: Ville Syrjälä <[email protected]>

This reverts commit 1b39e3f813b4685c7a30ae964d5529a1b0e3a286.

Makes my P3 machine oops somewhere in cpuidle. I suspect CONFIG_ACPI=n may have something to do with this.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

And if you don't do CONFIG_ACPI=n, does it still oops?

Don't think I actually tried that. I can give it a whirl tonight.

I think this machine should actually have ACPI, but it inherited the .config from a P2 machine that did not. Apparently I was too lazy to change .config when I swapped in the "new" machine.

I guess it would work, but never mind.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines

Anyway, there are later changes depending on this one, so reverting it won't work in general.

Let me look deeper at this.

What's there in /sys/devices/system/cpu/cpuidle/current_driver on your system with the problematic commit reverted?

# cat /sys/devices/system/cpu/cpuidle/current_driver
apm_idle

That is the key bit: I overlooked this little fellow.

Does the below (untested here) help?

---
 arch/x86/kernel/apm_32.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-pm/arch/x86/kernel/apm_32.c
===================================================================

arch/x86/kernel/apm_32.c static int __init apm_init(void) · line 2395

Quoted 7 lines
arch/x86/kernel/apm_32.c +1 -0
@@ -2389,6 +2389,7 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
+		cpuidle_poll_state_init(&apm_idle_driver);
 		if (!cpuidle_register_driver(&apm_idle_driver))
 			if (cpuidle_register_device(&apm_cpuidle_device))
 				cpuidle_unregister_driver(&apm_idle_driver);

Yep, this works. Thanks.

Quoted 1 line

Thanks!

Let me respin it with a changelog/tags etc

#7 lore raw

PATCH 1/1 x86: PM: Make APM idle driver initialize polling state

In reply to Ville Syrjälä

From: Rafael J. Wysocki <[email protected]>

Update the APM driver overlooked by commit 1b39e3f813b4 (cpuidle: Make drivers initialize polling state) to initialize the polling state like the other cpuidle drivers modified by that commit to prevent cpuidle from crashing.

Fixes 1b39e3f813b4 (cpuidle: Make drivers initialize polling state)
---
 arch/x86/kernel/apm_32.c |    1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/apm_32.c +1 -0
Index: linux-pm/arch/x86/kernel/apm_32.c
===================================================================
@@ -2389,6 +2389,7 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
+		cpuidle_poll_state_init(&apm_idle_driver);
 		if (!cpuidle_register_driver(&apm_idle_driver))
 			if (cpuidle_register_device(&apm_cpuidle_device))
 				cpuidle_unregister_driver(&apm_idle_driver);
#8 lore raw

Re: [PATCH] x86: PM: Make APM idle driver initialize polling state

Quoted 11 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Update the APM driver overlooked by commit 1b39e3f813b4 (cpuidle: Make drivers initialize polling state) to initialize the polling state like the other cpuidle drivers modified by that commit to prevent cpuidle from crashing.

Fixes 1b39e3f813b4 (cpuidle: Make drivers initialize polling state)

And maybe?

Cc <[email protected]> # v4.14+
Quoted 17 lines
---
 arch/x86/kernel/apm_32.c |    1 +
 1 file changed, 1 insertion(+)

Index: linux-pm/arch/x86/kernel/apm_32.c
===================================================================

arch/x86/kernel/apm_32.c +1 -0
@@ -2389,6 +2389,7 @@ static int __init apm_init(void)
 	if (HZ != 100)
 		idle_period = (idle_period * HZ) / 100;
 	if (idle_threshold < 100) {
+		cpuidle_poll_state_init(&apm_idle_driver);
 		if (!cpuidle_register_driver(&apm_idle_driver))
 			if (cpuidle_register_device(&apm_cpuidle_device))
 				cpuidle_unregister_driver(&apm_idle_driver);
Signature · 2 lines
Ville Syrjälä
Intel OTC
#9 lore raw

Re: [PATCH] x86: PM: Make APM idle driver initialize polling state

Quoted 8 lines · CET Ville Syrjälä
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Update the APM driver overlooked by commit 1b39e3f813b4 (cpuidle: Make drivers initialize polling state) to initialize the polling state like the other cpuidle drivers modified by that commit to prevent cpuidle from crashing.

Quoted 8 lines
Quoted 4 lines
Fixes 1b39e3f813b4 (cpuidle: Make drivers initialize polling state)

And maybe?

Cc <[email protected]> # v4.14+

I add these when applying patches.

Actually, I've queued up the patch with this tag already.

#10 lore raw

Re: [PATCH] x86: PM: Make APM idle driver initialize polling state

Quoted 14 lines · Rafael J. Wysocki
Quoted 13 lines · CET Ville Syrjälä
Quoted 11 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Update the APM driver overlooked by commit 1b39e3f813b4 (cpuidle: Make drivers initialize polling state) to initialize the polling state like the other cpuidle drivers modified by that commit to prevent cpuidle from crashing.

Fixes 1b39e3f813b4 (cpuidle: Make drivers initialize polling state)
Quoted 7 lines
Quoted 3 lines

And maybe?

Cc <[email protected]> # v4.14+

I add these when applying patches.

Actually, I've queued up the patch with this tag already.

Cool. Thanks.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#11 lore raw

PATCH 1/1 PM: cpuidle: Fix cpuidle_poll_state_init() prototype

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Commit f85942207516 (x86: PM: Make APM idle driver initialize polling state) made apm_init() call cpuidle_poll_state_init(), but that only is defined for CONFIG_CPU_IDLE set, so make the empty stub of it available for CONFIG_CPU_IDLE unset too to fix the resulting build issue.

Fixes f85942207516 (x86: PM: Make APM idle driver initialize polling state)
---
 include/linux/cpuidle.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/cpuidle.h +1 -1
Index: linux-pm/include/linux/cpuidle.h
===================================================================
@@ -225,7 +225,7 @@ static inline void cpuidle_coupled_paral
 }
 #endif
 
-#ifdef CONFIG_ARCH_HAS_CPU_RELAX
+#if defined(CONFIG_CPU_IDLE) && defined(CONFIG_ARCH_HAS_CPU_RELAX)
 void cpuidle_poll_state_init(struct cpuidle_driver *drv);
 #else
 static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {}