tools/power turbostat: regression fix: --show C1E%
Len Brown
maintainerPATCH 1/2 tools/power turbostat: regression fix: --show C1E%
From: Len Brown <[email protected]>
The new default idle counter groupings broke "--show C1E%" (or any other C-state %)
Also delete a stray debug printf from the same offending commit.
--- tools/power/x86/turbostat/turbostat.c | 4 ---- 1 file changed, 4 deletions(-)
tools/power/x86/turbostat/turbostat.c +0 -4
@@ -2429,7 +2429,6 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode) }if (i ==MAX_BIC ) { -fprintf (stderr,"deferred %s\n" , name_list);if (mode ==SHOW_LIST ) { deferred_add_names[deferred_add_index++] = name_list;if (deferred_add_index >=MAX_DEFERRED ) {
@@ -10537,9 +10536,6 @@ void probe_cpuidle_residency(void)int min_state =1024 , max_state =0 ;char *sp; -if (!DO_BIC (BIC_pct_idle)) -return ; -for (state =10 ; state >=0 ; --state) {sprintf (path,"/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name" , base_cpu, state);
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 2/2 tools/power turbostat: verify arguments to params --show and --hide
From: Len Brown <[email protected]>
$ sudo turbostat --quiet --show junk turbostat: Counter 'junk' can not be added.
Previously, invalid argumetns to --show and --hide were silently ignored
--- tools/power/x86/turbostat/turbostat.c | 33 +++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
tools/power/x86/turbostat/turbostat.c +31 -2
@@ -2310,6 +2310,8 @@ char *deferred_add_names[MAX_DEFERRED];char *deferred_skip_names[MAX_DEFERRED ];int deferred_add_index;int deferred_skip_index; +unsigned int deferred_add_consumed; +unsigned int deferred_skip_consumed;/* * HIDE_LIST - hide this list of counters, show the rest [default]
@@ -10512,8 +10514,10 @@ int is_deferred_add(char *name)int i;for (i =0 ; i < deferred_add_index; ++i) -if (!strcmp (name, deferred_add_names[i])) +if (!strcmp (name, deferred_add_names[i])) { + deferred_add_consumed |= (1 << i);return 1 ; + }return 0 ; }
@@ -10522,11 +10526,34 @@ int is_deferred_skip(char *name)int i;for (i =0 ; i < deferred_skip_index; ++i) -if (!strcmp (name, deferred_skip_names[i])) +if (!strcmp (name, deferred_skip_names[i])) { + deferred_skip_consumed |= (1 << i);return 1 ; + }return 0 ; } +void verify_deferred_consumed (void ) +{ +int i; +int fail =0 ; + +for (i =0 ; i < deferred_add_index; ++i) { +if (!(deferred_add_consumed & (1 << i))) { +warnx ("Counter '%s' can not be added." , deferred_add_names[i]); + fail++; + } + } +for (i =0 ; i < deferred_skip_index; ++i) { +if (!(deferred_skip_consumed & (1 << i))) { +warnx ("Counter '%s' can not be skipped." , deferred_skip_names[i]); + fail++; + } + } +if (fail) +exit (-EINVAL ); +} +void probe_cpuidle_residency (void ) {char path[64 ];
@@ -10885,6 +10912,8 @@ int main(int argc, char **argv)probe_cpuidle_residency ();probe_cpuidle_counts (); +verify_deferred_consumed (); +if (!getuid ())set_rlimit ();
Signature · 1 line
2.45.2
Re: [PATCH 2/2] tools/power turbostat: verify arguments to params --show and --hide
Quoted 7 lines · Len Brown
From: Len Brown <[email protected]>
$ sudo turbostat --quiet --show junk turbostat: Counter 'junk' can not be added.Previously, invalid argumetns to --show and --hide were silently ignored
s/argumetns/arguments
otherwise, the patch LGTM.
-rui
Quoted 79 lines
Signed-off-by Len Brown <[email protected]>---
tools/power/x86/turbostat/turbostat.c | 33 +++++++++++++++++++++++++--1 file changed, 31 insertions(+), 2 deletions(-)tools/power/x86/turbostat/turbostat.c +2
-0@@ -2310,6 +2310,8 @@ char *deferred_add_names[MAX_DEFERRED]; char *deferred_skip_names[MAX_DEFERRED]; int deferred_add_index; int deferred_skip_index; +unsigned int deferred_add_consumed; +unsigned int deferred_skip_consumed;
/*
*HIDE_LIST- hide this list of counters, show the rest [default]tools/power/x86/turbostat/turbostat.c +0
-0@@ -10512,8 +10514,10 @@ int is_deferred_add(char *name) int i;
for (i = 0; i <deferred_add_index; ++i)tools/power/x86/turbostat/turbostat.c +2
-1-if (!strcmp (name, deferred_add_names[i])) +if (!strcmp (name, deferred_add_names[i])) { + deferred_add_consumed |= (1 << i);return 1;
tools/power/x86/turbostat/turbostat.c +1
-0+ }return 0;
}tools/power/x86/turbostat/turbostat.c +0
-0@@ -10522,11 +10526,34 @@ int is_deferred_skip(char *name) int i;
for (i = 0; i <deferred_skip_index; ++i)tools/power/x86/turbostat/turbostat.c +2
-1-if (!strcmp (name, deferred_skip_names[i])) +if (!strcmp (name, deferred_skip_names[i])) { + deferred_skip_consumed |= (1 << i);return 1;
tools/power/x86/turbostat/turbostat.c +1
-0+ }return 0;
}tools/power/x86/turbostat/turbostat.c +8
-0+void verify_deferred_consumed (void ) +{ +int i; +int fail =0 ; + +for (i =0 ; i < deferred_add_index; ++i) { +if (!(deferred_add_consumed & (1 << i))) { + warnx("Counter '%s' can not be added.",deferred_add_names[i]);
tools/power/x86/turbostat/turbostat.c +6
-0+ fail++; + } + } +for (i =0 ; i < deferred_skip_index; ++i) { +if (!(deferred_skip_consumed & (1 << i))) { + warnx("Counter '%s' can not be skipped.",deferred_skip_names[i]);
tools/power/x86/turbostat/turbostat.c +7
-0+ fail++; + } + } +if (fail) +exit (-EINVAL ); +} +void
probe_cpuidle_residency(void)
{
char path[64];tools/power/x86/turbostat/turbostat.c +0
-0@@ -10885,6 +10912,8 @@ int main(int argc, char **argv) probe_cpuidle_residency(); probe_cpuidle_counts();tools/power/x86/turbostat/turbostat.c +2
-0+verify_deferred_consumed (); +if (!getuid())
set_rlimit();