Skip to contentSkip to conversation

cpuidle: Make cpuidle governor switchable to be the default behaviour

RFC PATCH Superseded Hanjun Guo 4 participants 7 messages Apr 27, 2020 – Apr 30, 2020 CPU idle time management framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Hanjun Guo

author
#0 lore raw

RFC PATCH 1/1 cpuidle: Make cpuidle governor switchable to be the default behaviour

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
 drivers/cpuidle/Kconfig | 9 +++++++++
 drivers/cpuidle/sysfs.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +9 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
 config DT_IDLE_STATES
 	bool
 
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+	bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+	help
+	  Make the CPU idle governor switchable at runtime, and make it as the
+	  default behaviour even the boot option "cpuidle_sysfs_switch" is not
+	  passed in cmdline.
+
+	  Say N if you unsure about this.
+
 menu "ARM CPU Idle Drivers"
 depends on ARM || ARM64
 source "drivers/cpuidle/Kconfig.arm"
drivers/cpuidle/sysfs.c +1 -1
index d3ef1d7..43701da 100644
@@ -146,7 +146,7 @@ static DEVICE_ATTR(current_governor, 0644, show_current_governor,
  */
 int cpuidle_add_interface(struct device *dev)
 {
-	if (sysfs_switch)
+	if (IS_ENABLED(CONFIG_CPU_IDLE_SWITCH_GOV_IN_DEFAULT) || sysfs_switch)
 		cpuidle_attr_group.attrs = cpuidle_switch_attrs;
 
 	return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
Signature · 1 line
1.7.12.4
#1 lore raw
Quoted 20 lines · Hanjun Guo

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
 drivers/cpuidle/Kconfig | 9 +++++++++
 drivers/cpuidle/sysfs.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
 config DT_IDLE_STATES

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 10 lines
drivers/cpuidle/Kconfig +8 -0
 	bool
 
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+	bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+	help
+	  Make the CPU idle governor switchable at runtime, and make it as the
+	  default behaviour even the boot option "cpuidle_sysfs_switch" is not
+	  passed in cmdline.
+
+	  Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

Quoted 17 lines
drivers/cpuidle/Kconfig +0 -0
 menu "ARM CPU Idle Drivers"
 depends on ARM || ARM64
 source "drivers/cpuidle/Kconfig.arm"
drivers/cpuidle/sysfs.c +1 -1
index d3ef1d7..43701da 100644
@@ -146,7 +146,7 @@ static DEVICE_ATTR(current_governor, 0644, show_current_governor,
  */
 int cpuidle_add_interface(struct device *dev)
 {
-	if (sysfs_switch)
+	if (IS_ENABLED(CONFIG_CPU_IDLE_SWITCH_GOV_IN_DEFAULT) || sysfs_switch)
 		cpuidle_attr_group.attrs = cpuidle_switch_attrs;
 
 	return sysfs_create_group(&dev->kobj, &cpuidle_attr_group);
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#2 lore raw

I very much support this RFC.
I have been running only with "cpuidle_sysfs_switch" for about 2 years.

Some changes would be required for the documentation files also.

Quoted 23 lines · On 2020.04.27 06:37 Daniel Lezcano wrote:
Quoted 22 lines · Hanjun Guo

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
 drivers/cpuidle/Kconfig | 9 +++++++++
 drivers/cpuidle/sysfs.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
 config DT_IDLE_STATES
 	bool
 
Quoted 10 lines

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 8 lines
drivers/cpuidle/Kconfig +8 -0
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+	bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+	help
+	  Make the CPU idle governor switchable at runtime, and make it as the
+	  default behaviour even the boot option "cpuidle_sysfs_switch" is not
+	  passed in cmdline.
+
+	  Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

Agree.

Quoted 3 lines

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

I do not like this _ro thing, and got hit by it with turbostat one time. Agree it should be made a candidate for removal.

author
#3 lore raw
Quoted 2 lines · Doug Smythies

I very much support this RFC.
I have been running only with "cpuidle_sysfs_switch" for about 2 years.

Thanks, glad to hear that switch cpuidle governor at runtime works for years.

Quoted 2 lines

Some changes would be required for the documentation files also.

I will update them in next version.

Quoted 36 lines · On 2020.04.27 06:37 Daniel Lezcano wrote:
Quoted 23 lines · Hanjun Guo
Quoted 22 lines

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
  drivers/cpuidle/Kconfig | 9 +++++++++
  drivers/cpuidle/sysfs.c | 2 +-
  2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
  config DT_IDLE_STATES
  	bool
 
Quoted 10 lines

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 8 lines
drivers/cpuidle/Kconfig +8 -0
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+	bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+	help
+	  Make the CPU idle governor switchable at runtime, and make it as the
+	  default behaviour even the boot option "cpuidle_sysfs_switch" is not
+	  passed in cmdline.
+
+	  Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

Quoted 8 lines

Agree.

Quoted 3 lines

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

I do not like this _ro thing, and got hit by it with turbostat one time. Agree it should be made a candidate for removal.

OK, I will prepare another RFC patch set to remove sysfs_switch.

Thanks
Hanjun

#4 lore raw
Quoted 51 lines · Hanjun Guo
Quoted 2 lines · Doug Smythies

I very much support this RFC.
I have been running only with "cpuidle_sysfs_switch" for about 2 years.

Thanks, glad to hear that switch cpuidle governor at runtime works for years.

Quoted 2 lines

Some changes would be required for the documentation files also.

I will update them in next version.

Quoted 38 lines · On 2020.04.27 06:37 Daniel Lezcano wrote:
Quoted 23 lines · Hanjun Guo
Quoted 22 lines

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
  drivers/cpuidle/Kconfig | 9 +++++++++
  drivers/cpuidle/sysfs.c | 2 +-
  2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
  config DT_IDLE_STATES
    bool
 
Quoted 10 lines

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 8 lines
drivers/cpuidle/Kconfig +8 -0
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+   bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+   help
+     Make the CPU idle governor switchable at runtime, and make it as the
+     default behaviour even the boot option "cpuidle_sysfs_switch" is not
+     passed in cmdline.
+
+     Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

Agree.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

I do not like this _ro thing, and got hit by it with turbostat one time. Agree it should be made a candidate for removal.

OK, I will prepare another RFC patch set to remove sysfs_switch.

I would just do it in one series, though, as suggested by Daniel.

Also, I wouldn't worry about the _ro thing too much, as the changes effectively make "cpuidle_sysfs_switch" be the default (and the tools should be able to cope with "cpuidle_sysfs_switch" anyway) without an alternative (but who cares?).

Cheers!

author
#5 lore raw
Quoted 56 lines · Rafael J. Wysocki
Quoted 55 lines · Hanjun Guo
Quoted 2 lines · Doug Smythies

I very much support this RFC.
I have been running only with "cpuidle_sysfs_switch" for about 2 years.

Thanks, glad to hear that switch cpuidle governor at runtime works for years.

Quoted 2 lines

Some changes would be required for the documentation files also.

I will update them in next version.

Quoted 42 lines · On 2020.04.27 06:37 Daniel Lezcano wrote:
Quoted 23 lines · Hanjun Guo
Quoted 22 lines

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
   drivers/cpuidle/Kconfig | 9 +++++++++
   drivers/cpuidle/sysfs.c | 2 +-
   2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
   config DT_IDLE_STATES
     bool
 
Quoted 10 lines

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 8 lines
drivers/cpuidle/Kconfig +8 -0
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+   bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+   help
+     Make the CPU idle governor switchable at runtime, and make it as the
+     default behaviour even the boot option "cpuidle_sysfs_switch" is not
+     passed in cmdline.
+
+     Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

Agree.

Quoted 3 lines

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I do not like this _ro thing, and got hit by it with turbostat one time. Agree it should be made a candidate for removal.

OK, I will prepare another RFC patch set to remove sysfs_switch.

I would just do it in one series, though, as suggested by Daniel.

OK, will sent out the patchset today.

Quoted 5 lines

Also, I wouldn't worry about the _ro thing too much, as the changes effectively make "cpuidle_sysfs_switch" be the default (and the tools should be able to cope with "cpuidle_sysfs_switch" anyway) without an alternative (but who cares?).

Thanks
Hanjun

author
#6 lore raw
In reply to Daniel Lezcano
Quoted 23 lines · Daniel Lezcano
Quoted 22 lines · Hanjun Guo

For now cpuidle governor can be switched via sysfs only when the boot option "cpuidle_sysfs_switch" is passed, but it's important to switch the governor to adapt to different workloads, especially after TEO and haltpoll governor were introduced.

Introduce a CONFIG option to make cpuidle governor switchable to be the default behaviour, which will not break the boot option behaviour.

---
  drivers/cpuidle/Kconfig | 9 +++++++++
  drivers/cpuidle/sysfs.c | 2 +-
  2 files changed, 10 insertions(+), 1 deletion(-)
drivers/cpuidle/Kconfig +0 -0
index c0aeedd..c40cb40 100644
@@ -47,6 +47,15 @@ config CPU_IDLE_GOV_HALTPOLL
  config DT_IDLE_STATES
  	bool
 
Quoted 10 lines

drivers/cpuidle/Kconfig config CPU_IDLE_GOV_HALTPOLL · line 57

Quoted 8 lines
drivers/cpuidle/Kconfig +8 -0
+config CPU_IDLE_SWITCH_GOV_IN_DEFAULT
+	bool "Switch the CPU idle governor via sysfs at runtime in default behaviour"
+	help
+	  Make the CPU idle governor switchable at runtime, and make it as the
+	  default behaviour even the boot option "cpuidle_sysfs_switch" is not
+	  passed in cmdline.
+
+	  Say N if you unsure about this.

Well I wouldn't make this optional but just remove the sysfs_switch.

That's my first solution but I send this RFC patch as it's less aggressive :), I'm happy to get your comments to remove the sysfs_switch, I will prepare patches for this solution.

Quoted 4 lines

However, there is the '_ro' suffix when the option is not set. In order to not break the existing tools, may be let both files co-exist and add in the ABI/obselete the '_ro' file as candidate for removal ?

Agreed.

Thanks
Hanjun