Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/cpupower: Choose base_cpu to display default cpupower details

The default output of cpupower info utils shows unexpected output
when CPU 0 is disabled.

Considering a case where CPU 0 is disabled, output of cpupower idle-info:

Before change:
cpupower idle-info
CPUidle driver: pseries_idle
CPUidle governor: menu
analyzing CPU 0:
*is offline

After change:
./cpupower idle-info
CPUidle driver: pseries_idle
CPUidle governor: menu
analyzing CPU 50:

Number of idle states: 2
Available idle states: snooze CEDE
snooze:
Flags/Description: snooze
Latency: 0
Usage: 101748
Duration: 2724058
CEDE:
Flags/Description: CEDE
Latency: 12
Usage: 270004
Duration: 283019526849

If -c option is not passed, CPU 0 was chosen as the default chosen CPU to
display details. However when CPU 0 is offline, it results in showing
unexpected output. This commit chooses the base_cpu
instead of CPU 0, hence keeping the output more relevant in all cases.
The base_cpu is the number of CPU on which the calling thread is
currently executing.

Signed-off-by: Saket Kumar Bhaskar <skb99@linux.vnet.ibm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Saket Kumar Bhaskar and committed by
Shuah Khan
5975e255 9abf2313

+6 -6
+2 -2
tools/power/cpupower/utils/cpufreq-info.c
··· 572 572 573 573 ret = 0; 574 574 575 - /* Default is: show output of CPU 0 only */ 575 + /* Default is: show output of base_cpu only */ 576 576 if (bitmask_isallclear(cpus_chosen)) 577 - bitmask_setbit(cpus_chosen, 0); 577 + bitmask_setbit(cpus_chosen, base_cpu); 578 578 579 579 switch (output_param) { 580 580 case -1:
+2 -2
tools/power/cpupower/utils/cpuidle-info.c
··· 176 176 cpuidle_exit(EXIT_FAILURE); 177 177 } 178 178 179 - /* Default is: show output of CPU 0 only */ 179 + /* Default is: show output of base_cpu only */ 180 180 if (bitmask_isallclear(cpus_chosen)) 181 - bitmask_setbit(cpus_chosen, 0); 181 + bitmask_setbit(cpus_chosen, base_cpu); 182 182 183 183 if (output_param == 0) 184 184 cpuidle_general_output();
+2 -2
tools/power/cpupower/utils/cpupower-info.c
··· 67 67 if (!params.params) 68 68 params.params = 0x7; 69 69 70 - /* Default is: show output of CPU 0 only */ 70 + /* Default is: show output of base_cpu only */ 71 71 if (bitmask_isallclear(cpus_chosen)) 72 - bitmask_setbit(cpus_chosen, 0); 72 + bitmask_setbit(cpus_chosen, base_cpu); 73 73 74 74 /* Add more per cpu options here */ 75 75 if (!params.perf_bias)