Some cpupower fixes
Hi Rafael,
can you queue up these patches in your tree/branch for kernel mainline inclusion, please.
Thanks!
Thomas
PATCH 1/3 cpupower: cpupower monitor reports uninitialized values for offline cpus
From: Jacob Tanenbaum <[email protected]>
[root@hp-dl980g7-02 linux]# cpupower monitor
...
5472| 0| 1|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 10567| 0| 159|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 1661206560|859272560| 150|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline 1661206560|943093104| 140|******|******|******|******|| 0.00| 0.00| 0.00| 0.00| 0.00 *is offline
because of this cpupower also holds the incorrect value for the number of physical packages in the machine
Changed cpupower to initialize the values of an offline cpu's socket and core to -1, warn the user that one or more cpus is/are offline and not print statistics for offline cpus.
This fix hides offlined cores where topology cannot be accessed. With a recent kernel patch suggested from Prarit Bhargava it may be possible that soft offlined cores' topology can still be parsed.
This patch would then show which cores in which package/socket are offline, when sane toplogoy information is available.
--- tools/power/cpupower/utils/helpers/topology.c | 23 ++++++++++++++-------- .../cpupower/utils/idle_monitor/cpupower-monitor.c | 9 ++++++++- 2 files changed, 23 insertions(+), 9 deletions(-)
tools/power/cpupower/utils/helpers/topology.c +15 -8
@@ -73,18 +73,22 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)for (cpu =0 ; cpu < cpus; cpu++) { cpu_top->core_info[cpu].cpu = cpu; cpu_top->core_info[cpu].is_online =sysfs_is_cpu_online (cpu); -if (!cpu_top->core_info[cpu].is_online) -continue ;if (sysfs_topology_read_file ( cpu,"physical_package_id" , - &(cpu_top->core_info[cpu].pkg)) <0 ) -return -1 ; + &(cpu_top->core_info[cpu].pkg)) <0 ) { + cpu_top->core_info[cpu].pkg =-1 ; + cpu_top->core_info[cpu].core =-1 ; +continue ; + }if (sysfs_topology_read_file ( cpu,"core_id" , - &(cpu_top->core_info[cpu].core)) <0 ) -return -1 ; + &(cpu_top->core_info[cpu].core)) <0 ) { + cpu_top->core_info[cpu].pkg =-1 ; + cpu_top->core_info[cpu].core =-1 ; +continue ; + } } qsort(cpu_top->core_info, cpus, sizeof(struct cpuid_core_info),
@@ -95,12 +99,15 @@ int get_cpu_topology(struct cpupower_topology *cpu_top)done by pkg value. */ last_pkg = cpu_top->core_info[0 ].pkg;for (cpu =1 ; cpu < cpus; cpu++) { -if (cpu_top->core_info[cpu].pkg != last_pkg) { +if (cpu_top->core_info[cpu].pkg != last_pkg && + cpu_top->core_info[cpu].pkg !=-1 ) { + last_pkg = cpu_top->core_info[cpu].pkg; cpu_top->pkgs++; } } - cpu_top->pkgs++; +if (!cpu_top->core_info[0 ].pkg ==-1 ) + cpu_top->pkgs++;/* Intel's cores count is not consecutively numbered, there may * be a core_id of 3, but none of 2. Assume there always is 0
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c +8 -1
@@ -143,6 +143,9 @@ void print_results(int topology_depth, int cpu)/* Be careful CPUs may got resorted for pkg value do not just use cpu */ if (!bitmask_isbitset (cpus_chosen, cpu_top.core_info[cpu].cpu))return ; +if (!cpu_top.core_info[cpu].is_online && + cpu_top.core_info[cpu].pkg ==-1 ) +return ;if (topology_depth >2 )printf ("%4d|" , cpu_top.core_info[cpu].pkg);
@@ -191,7 +194,8 @@ void print_results(int topology_depth, int cpu)* It's up to the monitor plug-in to check .is_online, this one * is just for additional info. */ -if (!cpu_top.core_info[cpu].is_online) { +if (!cpu_top.core_info[cpu].is_online && + cpu_top.core_info[cpu].pkg !=-1 ) {printf (_ (" *is offline\n" ));return ; }else
@@ -388,6 +392,9 @@ int cmd_monitor(int argc, char **argv)return EXIT_FAILURE ; } +if (!cpu_top.core_info[0 ].is_online) +printf ("WARNING: at least one cpu is offline\n" ); +/* Default is: monitor all CPUs */ if (bitmask_isallclear (cpus_chosen))bitmask_setall (cpus_chosen);
Signature · 1 line
2.1.4
PATCH 2/3 cpupower: Remove debug message when using cpupower idle-set -D switch
In reply to Thomas Renninger--- tools/power/cpupower/utils/cpuidle-set.c | 2 -- 1 file changed, 2 deletions(-)
tools/power/cpupower/utils/cpuidle-set.c +0 -2
@@ -148,8 +148,6 @@ int cmd_idle_set(int argc, char **argv) (cpu, idlestate); state_latency =sysfs_get_idlestate_latency (cpu, idlestate); -printf ("CPU: %u - idlestate %u - state_latency: %llu - latency: %llu\n" , - cpu, idlestate, state_latency, latency);if (disabled ==1 || latency > state_latency)continue ; ret = sysfs_idlestate_disable
Signature · 1 line
2.1.4
PATCH 3/3 cpupower: Enable disabled Cstates if they are below max latency
In reply to Thomas Renningercpupower idle-set -D <latency>
currently only disables all C-states that have a higher latency than the specified <latency>. But if deep sleep states were already disabled and have a lower latency, they should get enabled again.
For example:
This call:
cpupower idle-set -D 30
disables all C-states with a higher or equal latency than 30.
If one then calls:
cpupower idle-set -D 100
C-states with a latency between 30-99 will get enabled again with this patch now. It is ensured that only C-states with a latency of 100 and higher are disabled.
--- tools/power/cpupower/man/cpupower-idle-set.1 | 4 +++- tools/power/cpupower/utils/cpuidle-set.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-)
tools/power/cpupower/man/cpupower-idle-set.1 +3 -1
@@ -20,7 +20,9 @@ Disable a specific processor sleep state. Enable a specific processor sleep state. .TP \fB\-D\fR \fB\-\-disable-by-latency\fR <LATENCY> -Disable all idle states with a equal or higher latency than <LATENCY> +Disable all idle states with a equal or higher latency than <LATENCY>. + +Enable all idle states with a latency lower than <LATENCY>. .TP \fB\-E\fR \fB\-\-enable-all\fR Enable all idle states if not enabled already.
tools/power/cpupower/utils/cpuidle-set.c +13 -4
@@ -148,12 +148,21 @@ int cmd_idle_set(int argc, char **argv) (cpu, idlestate); state_latency =sysfs_get_idlestate_latency (cpu, idlestate); -if (disabled ==1 || latency > state_latency) +if (disabled ==1 ) { +if (latency > state_latency){ + ret =sysfs_idlestate_disable + (cpu, idlestate,0 ); +if (ret ==0 ) +printf (_ ("Idlestate %u enabled on CPU %u\n" ), idlestate, cpu); + }continue ; - ret =sysfs_idlestate_disable - (cpu, idlestate,1 ); -if (ret ==0 ) + } +if (latency <= state_latency){ + ret =sysfs_idlestate_disable + (cpu, idlestate,1 ); +if (ret ==0 )printf (_ ("Idlestate %u disabled on CPU %u\n" ), idlestate, cpu); + } }break ;case 'E' :
Signature · 1 line
2.1.4
PATCH 1/1 Creating a common structure initialization pattern for struct option
In reply to Thomas RenningerFrom: Sriram Raghunathan <[email protected]>
This patch tries to creates a common structure initialization within the cpupower tool.
Previously the ``struct option`` was initialized
using designated initializer technique which was
not needed. There were conflicting initialization methods seen with
bench/main.c & others.
--- tools/power/cpupower/debug/i386/dump_psb.c | 2 +- tools/power/cpupower/utils/cpufreq-info.c | 30 +++++++++++++++--------------- tools/power/cpupower/utils/cpufreq-set.c | 10 +++++----- tools/power/cpupower/utils/cpuidle-info.c | 4 ++-- tools/power/cpupower/utils/cpuidle-set.c | 14 +++++--------- tools/power/cpupower/utils/cpupower-info.c | 4 ++-- tools/power/cpupower/utils/cpupower-set.c | 2 +- 7 files changed, 31 insertions(+), 35 deletions(-)
tools/power/cpupower/debug/i386/dump_psb.c +1 -1
@@ -134,7 +134,7 @@ next_one: }static struct option info_opts[] = { - {.name ="numpst" , .has_arg=no_argument, .flag=NULL , .val='n' }, + {"numpst" , no_argument,NULL ,'n' }, };void print_help (void )
tools/power/cpupower/utils/cpufreq-info.c +15 -15
@@ -536,21 +536,21 @@ static int get_latency(unsigned int cpu, unsigned int human) }static struct option info_opts[] = { - { .name ="debug" , .has_arg = no_argument, .flag =NULL , .val ='e' }, - { .name ="boost" , .has_arg = no_argument, .flag =NULL , .val ='b' }, - { .name ="freq" , .has_arg = no_argument, .flag =NULL , .val ='f' }, - { .name ="hwfreq" , .has_arg = no_argument, .flag =NULL , .val ='w' }, - { .name ="hwlimits" , .has_arg = no_argument, .flag =NULL , .val ='l' }, - { .name ="driver" , .has_arg = no_argument, .flag =NULL , .val ='d' }, - { .name ="policy" , .has_arg = no_argument, .flag =NULL , .val ='p' }, - { .name ="governors" , .has_arg = no_argument, .flag =NULL , .val ='g' }, - { .name ="related-cpus" , .has_arg = no_argument, .flag =NULL , .val ='r' }, - { .name ="affected-cpus" ,.has_arg = no_argument, .flag =NULL , .val ='a' }, - { .name ="stats" , .has_arg = no_argument, .flag =NULL , .val ='s' }, - { .name ="latency" , .has_arg = no_argument, .flag =NULL , .val ='y' }, - { .name ="proc" , .has_arg = no_argument, .flag =NULL , .val ='o' }, - { .name ="human" , .has_arg = no_argument, .flag =NULL , .val ='m' }, - { .name ="no-rounding" , .has_arg = no_argument, .flag =NULL , .val ='n' }, + {"debug" , no_argument,NULL ,'e' }, + {"boost" , no_argument,NULL ,'b' }, + {"freq" , no_argument,NULL ,'f' }, + {"hwfreq" , no_argument,NULL ,'w' }, + {"hwlimits" , no_argument,NULL ,'l' }, + {"driver" , no_argument,NULL ,'d' }, + {"policy" , no_argument,NULL ,'p' }, + {"governors" , no_argument,NULL ,'g' }, + {"related-cpus" , no_argument,NULL ,'r' }, + {"affected-cpus" , no_argument,NULL ,'a' }, + {"stats" , no_argument,NULL ,'s' }, + {"latency" , no_argument,NULL ,'y' }, + {"proc" , no_argument,NULL ,'o' }, + {"human" , no_argument,NULL ,'m' }, + {"no-rounding" , no_argument,NULL ,'n' }, { }, };
tools/power/cpupower/utils/cpufreq-set.c +5 -5
@@ -22,11 +22,11 @@#define NORM_FREQ_LEN 32static struct option set_opts[] = { - { .name ="min" , .has_arg = required_argument, .flag =NULL , .val ='d' }, - { .name ="max" , .has_arg = required_argument, .flag =NULL , .val ='u' }, - { .name ="governor" , .has_arg = required_argument, .flag =NULL , .val ='g' }, - { .name ="freq" , .has_arg = required_argument, .flag =NULL , .val ='f' }, - { .name ="related" , .has_arg = no_argument, .flag =NULL , .val='r' }, + {"min" , required_argument,NULL ,'d' }, + {"max" , required_argument,NULL ,'u' }, + {"governor" , required_argument,NULL ,'g' }, + {"freq" , required_argument,NULL ,'f' }, + {"related" , no_argument,NULL ,'r' }, { }, };
tools/power/cpupower/utils/cpuidle-info.c +2 -2
@@ -126,8 +126,8 @@ static void proc_cpuidle_cpu_output(unsigned int cpu) }static struct option info_opts[] = { - { .name ="silent" , .has_arg = no_argument, .flag =NULL , .val ='s' }, - { .name ="proc" , .has_arg = no_argument, .flag =NULL , .val ='o' }, + {"silent" , no_argument,NULL ,'s' }, + {"proc" , no_argument,NULL ,'o' }, { }, };
tools/power/cpupower/utils/cpuidle-set.c +5 -9
@@ -13,15 +13,11 @@#include "helpers/sysfs.h" static struct option info_opts[] = { - { .name ="disable" , - .has_arg = required_argument, .flag =NULL , .val ='d' }, - { .name ="enable" , - .has_arg = required_argument, .flag =NULL , .val ='e' }, - { .name ="disable-by-latency" , - .has_arg = required_argument, .flag =NULL , .val ='D' }, - { .name ="enable-all" , - .has_arg = no_argument, .flag =NULL , .val ='E' }, - { }, + {"disable" , required_argument,NULL ,'d' }, + {"enable" , required_argument,NULL ,'e' }, + {"disable-by-latency" , required_argument,NULL ,'D' }, + {"enable-all" , no_argument,NULL ,'E' }, + { }, };
tools/power/cpupower/utils/cpupower-info.c +2 -2
@@ -17,8 +17,8 @@#include "helpers/sysfs.h" static struct option set_opts[] = { - { .name ="perf-bias" , .has_arg = optional_argument, .flag =NULL , .val ='b' }, - { }, + {"perf-bias" , optional_argument,NULL ,'b' }, + { }, };static void print_wrong_arg_exit (void )
tools/power/cpupower/utils/cpupower-set.c +1 -1
@@ -18,7 +18,7 @@#include "helpers/bitmask.h" static struct option set_opts[] = { - { .name ="perf-bias" , .has_arg = required_argument, .flag =NULL , .val ='b' }, + {"perf-bias" , required_argument,NULL ,'b' }, { }, };
Signature · 1 line
2.1.4
Quoted 4 lines · Thomas Renninger
Hi Rafael,
can you queue up these patches in your tree/branch for kernel mainline inclusion, please.
I've queued them up for the next PM+ACPI pull request.
Thanks,
Rafael