Use the ladder cpuidle governor when appropriate
Subsystems (2)
cover Use the ladder cpuidle governor when appropriate
Hi all,
This is my attempt to fix:
https://bugzilla.kernel.org/show_bug.cgi?id=65531
[PATCH 1/3] nohz: Expose tick_nohz_enabled
[PATCH 2/3] cpuidle: Default to ladder governor on ticking systems [PATCH 3/3] cpuidle: Don't enable all governors by default
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH 1/3 Subject: nohz: Expose tick_nohz_enabled
The cpuidle subsystem needs it.
--- include/linux/tick.h | 2 ++ kernel/time/tick-sched.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/linux/tick.h +2 -0
@@ -98,6 +98,7 @@ static inline void tick_broadcast_exit(v }#ifdef CONFIG_NO_HZ_COMMON +extern int tick_nohz_enabled;extern int tick_nohz_tick_stopped (void );extern void tick_nohz_idle_enter (void );extern void tick_nohz_idle_exit (void );
@@ -106,6 +107,7 @@ extern ktime_t tick_nohz_get_sleep_lengtextern u64 get_cpu_idle_time_us (int cpu,u64 *last_update_time);extern u64 get_cpu_iowait_time_us (int cpu,u64 *last_update_time);#else /* !CONFIG_NO_HZ_COMMON */ +#define tick_nohz_enabled (0)static inline int tick_nohz_tick_stopped (void ) {return 0 ; }static inline void tick_nohz_idle_enter (void ) { }static inline void tick_nohz_idle_exit (void ) { }
kernel/time/tick-sched.c +1 -1
@@ -387,7 +387,7 @@ void __init tick_nohz_init(void)/* * NO HZ enabled ? */ -static int tick_nohz_enabled__read_mostly =1 ; +int tick_nohz_enabled__read_mostly =1 ;unsigned long tick_nohz_active__read_mostly ;/* * Enable / Disable tickless mode
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH 2/3 cpuidle: Default to ladder governor on ticking systems
In reply to Jean DelvareThe menu governor is currently the default on all systems. However the documentation claims that the ladder governor is preferred on ticking systems. So bump the rating of the ladder governor when NO_HZ is disabled, or when booting with nohz=off.
This fixes the first half of bug #65531:
https://bugzilla.kernel.org/show_bug.cgi?id=65531
--- drivers/cpuidle/governors/ladder.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/cpuidle/governors/ladder.c +9 -0
@@ -17,6 +17,7 @@#include <linux/pm_qos.h> #include <linux/module.h> #include <linux/jiffies.h> +#include <linux/tick.h> #include <asm/io.h> #include <asm/uaccess.h>
@@ -184,6 +185,14 @@ static struct cpuidle_governor ladder_go*/ static int __init init_ladder (void ) { +/* +* When NO_HZ is disabled, or when booting with nohz=off, the ladder +* governor is better so give it a higher rating than the menu +* governor. +*/ +if (!tick_nohz_enabled) + ladder_governor.rating =25 ; +return cpuidle_register_governor (&ladder_governor); }
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH 3/3 cpuidle: Don't enable all governors by default
In reply to Jean DelvareSince commit d6f346f2d2 ("cpuidle: improve governor Kconfig options") the best cpuidle governor is selected automatically. There is little point in additionally selecting the other as it will not be used. So don't make it the default.
Being able to select more than one governor is still good for developers booting with cpuidle_sysfs_switch.
This fixes the second half of bug #65531:
https://bugzilla.kernel.org/show_bug.cgi?id=65531
--- drivers/cpuidle/Kconfig | 2 -- 1 file changed, 2 deletions(-)
drivers/cpuidle/Kconfig +0 -2
@@ -19,11 +19,9 @@ config CPU_IDLE_MULTIPLE_DRIVERS config CPU_IDLE_GOV_LADDER bool "Ladder governor (for periodic timer tick)" - default y config CPU_IDLE_GOV_MENU bool "Menu governor (for tickless system)" - default y config DT_IDLE_STATES bool
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH 1/3] Subject: nohz: Expose tick_nohz_enabled
In reply to Jean DelvareBah, sorry for the wonky subject :(
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH 1/3] Subject: nohz: Expose tick_nohz_enabled
In reply to Jean DelvareQuoted 5 lines · Jean Delvare
The cpuidle subsystem needs it.
Signed-off-by Jean Delvare <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Zhang Rui <[email protected]>
Quoted 39 lines
--- include/linux/tick.h | 2 ++ kernel/time/tick-sched.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)include/linux/tick.h +2
-0@@ -98,6 +98,7 @@ static inline void tick_broadcast_exit(v }#ifdef CONFIG_NO_HZ_COMMON +extern int tick_nohz_enabled;extern int tick_nohz_tick_stopped (void );extern void tick_nohz_idle_enter (void );extern void tick_nohz_idle_exit (void );@@ -106,6 +107,7 @@ extern ktime_t tick_nohz_get_sleep_lengtextern u64 get_cpu_idle_time_us (int cpu,u64 *last_update_time);extern u64 get_cpu_iowait_time_us (int cpu,u64 *last_update_time);#else /* !CONFIG_NO_HZ_COMMON */ +#define tick_nohz_enabled (0)static inline int tick_nohz_tick_stopped (void ) {return 0 ; }static inline void tick_nohz_idle_enter (void ) { }static inline void tick_nohz_idle_exit (void ) { }kernel/time/tick-sched.c +1
-1@@ -387,7 +387,7 @@ void __init tick_nohz_init(void)/* * NO HZ enabled ? */ -static int tick_nohz_enabled__read_mostly =1 ; +int tick_nohz_enabled__read_mostly =1 ;unsigned long tick_nohz_active__read_mostly ;/* * Enable / Disable tickless mode Signature · 3 lines
-- Jean Delvare SUSE L3 Support