ACPI/cpuidle cleanups - Rename cpuidle states, cleanup idle= usage/processing
Subsystems (4)
Hi Len,
these are some not pressing cleanups.
It would be great to see them in your test branch.
I missed out (and won't send again) the idle=halt change in processor_idle.c As you mentioned that x86 might always register for cpuidle, this change would not make sense.
Compile tested, based on latest Linus tree.
Thanks,
Thomas
PATCH 1/3 acpi: Use ACPI C-state type instead of enumeration value to export cpuidle state name
In the former /proc/acpi/processor/power/* there were Cx showing the enumerated number/amount of C-states and type[Cy] which is what should get shown as the cpuidle state name.
--- drivers/acpi/processor_idle.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/acpi/processor_idle.c +3 -1
@@ -1008,7 +1008,6 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)#endif cpuidle_set_statedata (state, cx); -snprintf (state->name,CPUIDLE_NAME_LEN ,"C%d" , i);strncpy (state->desc, cx->desc,CPUIDLE_DESC_LEN ); state->exit_latency = cx->latency; state->target_residency = cx->latency * latency_factor;
@@ -1016,6 +1015,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr) state->flags =0 ;switch (cx->type) {case ACPI_STATE_C1 : +snprintf (state->name,CPUIDLE_NAME_LEN ,"C1" ); state->flags |=CPUIDLE_FLAG_SHALLOW ;if (cx->entry_method ==ACPI_CSTATE_FFH ) state->flags |=CPUIDLE_FLAG_TIME_VALID ;
@@ -1025,6 +1025,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)break ;case ACPI_STATE_C2 : +snprintf (state->name,CPUIDLE_NAME_LEN ,"C2" ); state->flags |=CPUIDLE_FLAG_BALANCED ; state->flags |=CPUIDLE_FLAG_TIME_VALID ; state->enter = acpi_idle_enter_simple;
@@ -1032,6 +1033,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)break ;case ACPI_STATE_C3 : +snprintf (state->name,CPUIDLE_NAME_LEN ,"C3" ); state->flags |=CPUIDLE_FLAG_DEEP ; state->flags |=CPUIDLE_FLAG_TIME_VALID ; state->flags |=CPUIDLE_FLAG_CHECK_BM ;
Signature · 1 line
1.6.3
PATCH 2/3 cpuidle: Rename X86 specific idle poll state[0] from C0 to CPUIDLE
In reply to Thomas RenningerC0 means and is well know as "not idle".
All documentation out there uses this term as "running"/"not idle" state. Also Linux userspace tools (e.g. cpufreq-aperf and turbostat) show C0 residency which there is correct, but means something totally else than cpuidle "CPUIDLE" state.
--- drivers/cpuidle/cpuidle.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle.c +2 -2
@@ -260,8 +260,8 @@ static void poll_idle_init(struct cpuidle_device *dev)cpuidle_set_statedata (state,NULL ); -snprintf (state->name,CPUIDLE_NAME_LEN ,"C0" ); -snprintf (state->desc,CPUIDLE_DESC_LEN ,"CPUIDLE CORE POLL IDLE" ); +snprintf (state->name,CPUIDLE_NAME_LEN ,"CPUIDLE" ); +snprintf (state->desc,CPUIDLE_DESC_LEN ,"CORE POLL IDLE" ); state->exit_latency =0 ; state->target_residency =0 ; state->power_usage =-1 ;
Signature · 1 line
1.6.3
Re: [PATCH 2/3] cpuidle: Rename X86 specific idle poll state[0] from C0 to CPUIDLE
Quoted 5 lines · Thomas Renninger
C0 means and is well know as "not idle".
All documentation out there uses this term as "running"/"not idle" state. Also Linux userspace tools (e.g. cpufreq-aperf and turbostat) show C0 residency which there is correct, but means something totally else than cpuidle "CPUIDLE" state.
...
drivers/cpuidle/cpuidle.c static void poll_idle_init(struct cpuidle_device *dev) · line 263
Quoted 4 lines
drivers/cpuidle/cpuidle.c +1
-2-snprintf (state->name,CPUIDLE_NAME_LEN ,"C0" ); -snprintf (state->desc,CPUIDLE_DESC_LEN ,"CPUIDLE CORE POLL IDLE" ); +snprintf (state->name,CPUIDLE_NAME_LEN ,"CPUIDLE" );
An even better name might be POLL_IDLE, this corresponds to idle=poll and other (function,..) names in the kernel and people immediately get a picture what this state is about.
Comments?
Shall I resend or could you rename it to whatever you think fits best. I don't care much about the name, but it must not be called C0...
Thanks,
Thomas
PATCH 3/3 X86: Cleanup idle= internal variables by getting rid of idle_halt idle_nomwait
In reply to Thomas RenningerHaving four variables for the same thing:
idle_halt, idle_nomwait, force_mwait and boot_option_idle_overrides
is rather confusing and unnecessary complex.
if idle= boot param is passed, only set up one variable:boot_option_idle_overrides
Introduces following functional changes/fixes:
- intel_idle driver does not register if any idle=xy boot param is passed.
--- arch/ia64/include/asm/processor.h | 5 +++-- arch/ia64/kernel/process.c | 6 +----- arch/x86/include/asm/processor.h | 5 +++-- arch/x86/kernel/process.c | 24 ++++++++---------------- drivers/acpi/processor_core.c | 4 ++-- drivers/acpi/processor_idle.c | 17 ++++++++++++----- drivers/idle/intel_idle.c | 4 ++++ 7 files changed, 33 insertions(+), 32 deletions(-)
arch/ia64/include/asm/processor.h +3 -2
@@ -717,8 +717,9 @@ prefetchw (const void *x)#define spin_lock_prefetch (x) prefetchw(x)extern unsigned long boot_option_idle_override; -extern unsigned long idle_halt; -extern unsigned long idle_nomwait; + +enum idle_boot_override {IDLE_NO_OVERRIDE =0 ,IDLE_HALT ,IDLE_FORCE_MWAIT , +IDLE_NOMWAIT ,IDLE_POLL };#endif /* !__ASSEMBLY__ */
arch/ia64/kernel/process.c +1 -5
@@ -53,12 +53,8 @@void (*ia64_mark_idle)(int ); -unsigned long boot_option_idle_override =0 ; +unsigned long boot_option_idle_override =IDLE_NO_OVERRIDE ;EXPORT_SYMBOL (boot_option_idle_override); -unsigned long idle_halt; -EXPORT_SYMBOL (idle_halt); -unsigned long idle_nomwait; -EXPORT_SYMBOL (idle_nomwait);void (*pm_idle) (void );EXPORT_SYMBOL (pm_idle);void (*pm_power_off) (void );
arch/x86/include/asm/processor.h +3 -2
@@ -762,10 +762,11 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c);extern void init_c1e_mask (void );extern unsigned long boot_option_idle_override; -extern unsigned long idle_halt; -extern unsigned long idle_nomwait;extern bool c1e_detected; +enum idle_boot_override {IDLE_NO_OVERRIDE =0 ,IDLE_HALT ,IDLE_NOMWAIT , +IDLE_POLL ,IDLE_FORCE_MWAIT }; +extern void enable_sep_cpu (void );extern int sysenter_setup (void );
arch/x86/kernel/process.c +8 -16
@@ -22,11 +22,6 @@#include <asm/i387.h> #include <asm/debugreg.h> -unsigned long idle_halt; -EXPORT_SYMBOL (idle_halt); -unsigned long idle_nomwait; -EXPORT_SYMBOL (idle_nomwait); -struct kmem_cache *task_xstate_cachep;EXPORT_SYMBOL_GPL (task_xstate_cachep);
@@ -328,7 +323,7 @@ long sys_execve(const char __user *name,/* * Idle related variables and functions */ -unsigned long boot_option_idle_override =0 ; +unsigned long boot_option_idle_override =IDLE_NO_OVERRIDE ;EXPORT_SYMBOL (boot_option_idle_override);/*
@@ -504,7 +499,6 @@ static void poll_idle(void)* * idle=mwait overrides this decision and forces the usage of mwait. */ -static int __cpuinitdata force_mwait;#define MWAIT_INFO 0x05#define MWAIT_ECX_EXTENDED_INFO 0x01
@@ -514,7 +508,7 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c) {u32 eax, ebx, ecx, edx; -if (force_mwait) +if (boot_option_idle_override ==IDLE_FORCE_MWAIT )return 1 ;if (c->cpuid_level <MWAIT_INFO )
@@ -634,9 +628,10 @@ static int __init idle_setup(char *str)if (!strcmp (str,"poll" )) {printk ("using polling idle threads.\n" ); pm_idle = poll_idle; - }else if (!strcmp (str,"mwait" )) - force_mwait =1 ; -else if (!strcmp (str,"halt" )) { + boot_option_idle_override =IDLE_POLL ; + }else if (!strcmp (str,"mwait" )) { + boot_option_idle_override =IDLE_FORCE_MWAIT ; + }else if (!strcmp (str,"halt" )) {/* * When the boot option of idle=halt is added, halt is * forced to be used for CPU idle. In such case CPU C2/C3
@@ -645,8 +640,7 @@ static int __init idle_setup(char *str)* the boot_option_idle_override. */ pm_idle = default_idle; - idle_halt =1 ; -return 0 ; + boot_option_idle_override =IDLE_HALT ; }else if (!strcmp (str,"nomwait" )) {/* * If the boot option of "idle=nomwait" is added,
@@ -654,12 +648,10 @@ static int __init idle_setup(char *str)* states. In such case it won't touch the variable * of boot_option_idle_override. */ - idle_nomwait =1 ; -return 0 ; + boot_option_idle_override =IDLE_NOMWAIT ; }else return -1 ; - boot_option_idle_override =1 ;return 0 ; }early_param ("idle" , idle_setup);
drivers/acpi/processor_core.c +2 -2
@@ -23,7 +23,7 @@ static int set_no_mwait(const struct dmi_system_id *id) { printk(KERN_NOTICE PREFIX "%s detected - " "disabling mwait for CPU C-states\n", id->ident); - idle_nomwait =1 ; + boot_option_idle_override =IDLE_NOMWAIT ;return 0 ; }
@@ -283,7 +283,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) {acpi_status status =AE_OK ; -if (idle_nomwait) { +if (boot_option_idle_override ==IDLE_NOMWAIT ) {/* * If mwait is disabled for CPU C-states, the C2C3_FFH access * mode will be disabled in the parameter of _PDC object.
drivers/acpi/processor_idle.c +12 -5
@@ -79,6 +79,12 @@ module_param(bm_check_disable, uint, 0000);static unsigned int latency_factor__read_mostly =2 ;module_param (latency_factor, uint,0644 ); +static int disabled_by_idle_boot_param (void ) +{ +return boot_option_idle_override ==IDLE_POLL || + boot_option_idle_override ==IDLE_FORCE_MWAIT ; +} +/* * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. * For now disable this. Probably a bug somewhere else.
@@ -455,7 +461,8 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)continue ; }if (cx.type ==ACPI_STATE_C1 && - (idle_halt || idle_nomwait)) { + (boot_option_idle_override ==IDLE_HALT || + boot_option_idle_override ==IDLE_NOMWAIT )) {/* * In most cases the C1 space_id obtained from * _CST object is FIXED_HARDWARE access mode.
@@ -1060,7 +1067,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) {int ret =0 ; -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;if (!pr)
@@ -1091,11 +1098,11 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,acpi_status status =0 ;static int first_run; -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;if (!first_run) { -if (idle_halt) { +if (boot_option_idle_override ==IDLE_HALT ) {/* * When the boot option of "idle=halt" is added, halt * is used for CPU IDLE.
@@ -1144,7 +1151,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,int acpi_processor_power_exit (struct acpi_processor *pr,struct acpi_device *device) { -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;cpuidle_unregister_device (&pr->power.dev);
drivers/idle/intel_idle.c +4 -0
@@ -409,6 +409,10 @@ static int __init intel_idle_init(void) {int retval; +/* Do not load intel_idle at all for now if idle= is passed */ +if (boot_option_idle_override !=IDLE_NO_OVERRIDE ) +return -ENODEV ; + retval =intel_idle_probe ();if (retval)return retval;
Signature · 1 line
1.6.3
PATCH 3/3 X86: Cleanup idle= internal variables by getting rid of idle_halt idle_nomwait
In reply to Thomas RenningerHaving four variables for the same thing:
idle_halt, idle_nomwait, force_mwait and boot_option_idle_overrides
is rather confusing and unnecessary complex.
if idle= boot param is passed, only set up one variable:boot_option_idle_overrides
Introduces following functional changes/fixes:
- intel_idle driver does not register if any idle=xy boot param is passed.
--- arch/ia64/include/asm/processor.h | 5 +++-- arch/ia64/kernel/process.c | 6 +----- arch/x86/include/asm/processor.h | 5 +++-- arch/x86/kernel/process.c | 24 ++++++++---------------- drivers/acpi/processor_core.c | 4 ++-- drivers/acpi/processor_idle.c | 17 ++++++++++++----- drivers/idle/intel_idle.c | 4 ++++ 7 files changed, 33 insertions(+), 32 deletions(-)
arch/ia64/include/asm/processor.h +3 -2
@@ -717,8 +717,9 @@ prefetchw (const void *x)#define spin_lock_prefetch (x) prefetchw(x)extern unsigned long boot_option_idle_override; -extern unsigned long idle_halt; -extern unsigned long idle_nomwait; + +enum idle_boot_override {IDLE_NO_OVERRIDE =0 ,IDLE_HALT ,IDLE_FORCE_MWAIT , +IDLE_NOMWAIT ,IDLE_POLL };#endif /* !__ASSEMBLY__ */
arch/ia64/kernel/process.c +1 -5
@@ -53,12 +53,8 @@void (*ia64_mark_idle)(int ); -unsigned long boot_option_idle_override =0 ; +unsigned long boot_option_idle_override =IDLE_NO_OVERRIDE ;EXPORT_SYMBOL (boot_option_idle_override); -unsigned long idle_halt; -EXPORT_SYMBOL (idle_halt); -unsigned long idle_nomwait; -EXPORT_SYMBOL (idle_nomwait);void (*pm_idle) (void );EXPORT_SYMBOL (pm_idle);void (*pm_power_off) (void );
arch/x86/include/asm/processor.h +3 -2
@@ -762,10 +762,11 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c);extern void init_c1e_mask (void );extern unsigned long boot_option_idle_override; -extern unsigned long idle_halt; -extern unsigned long idle_nomwait;extern bool c1e_detected; +enum idle_boot_override {IDLE_NO_OVERRIDE =0 ,IDLE_HALT ,IDLE_NOMWAIT , +IDLE_POLL ,IDLE_FORCE_MWAIT }; +extern void enable_sep_cpu (void );extern int sysenter_setup (void );
arch/x86/kernel/process.c +8 -16
@@ -22,11 +22,6 @@#include <asm/i387.h> #include <asm/debugreg.h> -unsigned long idle_halt; -EXPORT_SYMBOL (idle_halt); -unsigned long idle_nomwait; -EXPORT_SYMBOL (idle_nomwait); -struct kmem_cache *task_xstate_cachep;EXPORT_SYMBOL_GPL (task_xstate_cachep);
@@ -328,7 +323,7 @@ long sys_execve(const char __user *name,/* * Idle related variables and functions */ -unsigned long boot_option_idle_override =0 ; +unsigned long boot_option_idle_override =IDLE_NO_OVERRIDE ;EXPORT_SYMBOL (boot_option_idle_override);/*
@@ -504,7 +499,6 @@ static void poll_idle(void)* * idle=mwait overrides this decision and forces the usage of mwait. */ -static int __cpuinitdata force_mwait;#define MWAIT_INFO 0x05#define MWAIT_ECX_EXTENDED_INFO 0x01
@@ -514,7 +508,7 @@ static int __cpuinit mwait_usable(const struct cpuinfo_x86 *c) {u32 eax, ebx, ecx, edx; -if (force_mwait) +if (boot_option_idle_override ==IDLE_FORCE_MWAIT )return 1 ;if (c->cpuid_level <MWAIT_INFO )
@@ -634,9 +628,10 @@ static int __init idle_setup(char *str)if (!strcmp (str,"poll" )) {printk ("using polling idle threads.\n" ); pm_idle = poll_idle; - }else if (!strcmp (str,"mwait" )) - force_mwait =1 ; -else if (!strcmp (str,"halt" )) { + boot_option_idle_override =IDLE_POLL ; + }else if (!strcmp (str,"mwait" )) { + boot_option_idle_override =IDLE_FORCE_MWAIT ; + }else if (!strcmp (str,"halt" )) {/* * When the boot option of idle=halt is added, halt is * forced to be used for CPU idle. In such case CPU C2/C3
@@ -645,8 +640,7 @@ static int __init idle_setup(char *str)* the boot_option_idle_override. */ pm_idle = default_idle; - idle_halt =1 ; -return 0 ; + boot_option_idle_override =IDLE_HALT ; }else if (!strcmp (str,"nomwait" )) {/* * If the boot option of "idle=nomwait" is added,
@@ -654,12 +648,10 @@ static int __init idle_setup(char *str)* states. In such case it won't touch the variable * of boot_option_idle_override. */ - idle_nomwait =1 ; -return 0 ; + boot_option_idle_override =IDLE_NOMWAIT ; }else return -1 ; - boot_option_idle_override =1 ;return 0 ; }early_param ("idle" , idle_setup);
drivers/acpi/processor_core.c +2 -2
@@ -23,7 +23,7 @@ static int set_no_mwait(const struct dmi_system_id *id) { printk(KERN_NOTICE PREFIX "%s detected - " "disabling mwait for CPU C-states\n", id->ident); - idle_nomwait =1 ; + boot_option_idle_override =IDLE_NOMWAIT ;return 0 ; }
@@ -283,7 +283,7 @@ acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in) {acpi_status status =AE_OK ; -if (idle_nomwait) { +if (boot_option_idle_override ==IDLE_NOMWAIT ) {/* * If mwait is disabled for CPU C-states, the C2C3_FFH access * mode will be disabled in the parameter of _PDC object.
drivers/acpi/processor_idle.c +12 -5
@@ -79,6 +79,12 @@ module_param(bm_check_disable, uint, 0000);static unsigned int latency_factor__read_mostly =2 ;module_param (latency_factor, uint,0644 ); +static int disabled_by_idle_boot_param (void ) +{ +return boot_option_idle_override ==IDLE_POLL || + boot_option_idle_override ==IDLE_FORCE_MWAIT ; +} +/* * IBM ThinkPad R40e crashes mysteriously when going into C2 or C3. * For now disable this. Probably a bug somewhere else.
@@ -455,7 +461,8 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)continue ; }if (cx.type ==ACPI_STATE_C1 && - (idle_halt || idle_nomwait)) { + (boot_option_idle_override ==IDLE_HALT || + boot_option_idle_override ==IDLE_NOMWAIT )) {/* * In most cases the C1 space_id obtained from * _CST object is FIXED_HARDWARE access mode.
@@ -1060,7 +1067,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr) {int ret =0 ; -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;if (!pr)
@@ -1091,11 +1098,11 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,acpi_status status =0 ;static int first_run; -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;if (!first_run) { -if (idle_halt) { +if (boot_option_idle_override ==IDLE_HALT ) {/* * When the boot option of "idle=halt" is added, halt * is used for CPU IDLE.
@@ -1144,7 +1151,7 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,int acpi_processor_power_exit (struct acpi_processor *pr,struct acpi_device *device) { -if (boot_option_idle_override) +if (disabled_by_idle_boot_param ())return 0 ;cpuidle_unregister_device (&pr->power.dev);
drivers/idle/intel_idle.c +4 -0
@@ -409,6 +409,10 @@ static int __init intel_idle_init(void) {int retval; +/* Do not load intel_idle at all for now if idle= is passed */ +if (boot_option_idle_override !=IDLE_NO_OVERRIDE ) +return -ENODEV ; + retval =intel_idle_probe ();if (retval)return retval;
Signature · 1 line
1.6.3