Skip to content

Commit 0fc521b

Browse files
Zephaniah E. Loss-Cutler-Hulllenb
authored andcommitted
tools/power turbostat: Allow -e for all names.
Currently, there are a number of variables which are displayed by default, enabled with -e all, and listed by --list, but which you can not give to --enable/-e. So you can enable CPU0c1 (in the bic array), but you can't enable C1 or C1% (not in the bic array, but exists in sysfs). This runs counter to both the documentation and user expectations, and it's just not very user friendly. As such, the mechanism used by --hide has been duplicated, and is now also used by --enable, so we can handle unknown names gracefully. Note: One impact of this is that truly unknown fields given to --enable will no longer generate errors, they will be silently ignored, as --hide does. Signed-off-by: Zephaniah E. Loss-Cutler-Hull <zephaniah@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 6b39862 commit 0fc521b

1 file changed

Lines changed: 35 additions & 14 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs | BIC_APIC | BIC
686686
#define BIC_IS_ENABLED(COUNTER_BIT) (bic_enabled & COUNTER_BIT)
687687

688688
#define MAX_DEFERRED 16
689+
char *deferred_add_names[MAX_DEFERRED];
689690
char *deferred_skip_names[MAX_DEFERRED];
691+
int deferred_add_index;
690692
int deferred_skip_index;
691693

692694
/*
@@ -780,17 +782,23 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
780782
}
781783
if (i == MAX_BIC) {
782784
if (mode == SHOW_LIST) {
783-
fprintf(stderr, "Invalid counter name: %s\n", name_list);
784-
exit(-1);
785-
}
786-
deferred_skip_names[deferred_skip_index++] = name_list;
787-
if (debug)
788-
fprintf(stderr, "deferred \"%s\"\n", name_list);
789-
if (deferred_skip_index >= MAX_DEFERRED) {
790-
fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n",
791-
MAX_DEFERRED, name_list);
792-
help();
793-
exit(1);
785+
deferred_add_names[deferred_add_index++] = name_list;
786+
if (deferred_add_index >= MAX_DEFERRED) {
787+
fprintf(stderr, "More than max %d un-recognized --add options '%s'\n",
788+
MAX_DEFERRED, name_list);
789+
help();
790+
exit(1);
791+
}
792+
} else {
793+
deferred_skip_names[deferred_skip_index++] = name_list;
794+
if (debug)
795+
fprintf(stderr, "deferred \"%s\"\n", name_list);
796+
if (deferred_skip_index >= MAX_DEFERRED) {
797+
fprintf(stderr, "More than max %d un-recognized --skip options '%s'\n",
798+
MAX_DEFERRED, name_list);
799+
help();
800+
exit(1);
801+
}
794802
}
795803
}
796804

@@ -6152,6 +6160,16 @@ void parse_add_command(char *add_command)
61526160
}
61536161
}
61546162

6163+
int is_deferred_add(char *name)
6164+
{
6165+
int i;
6166+
6167+
for (i = 0; i < deferred_add_index; ++i)
6168+
if (!strcmp(name, deferred_add_names[i]))
6169+
return 1;
6170+
return 0;
6171+
}
6172+
61556173
int is_deferred_skip(char *name)
61566174
{
61576175
int i;
@@ -6170,9 +6188,6 @@ void probe_sysfs(void)
61706188
int state;
61716189
char *sp;
61726190

6173-
if (!DO_BIC(BIC_sysfs))
6174-
return;
6175-
61766191
for (state = 10; state >= 0; --state) {
61776192

61786193
sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name", base_cpu, state);
@@ -6195,6 +6210,9 @@ void probe_sysfs(void)
61956210

61966211
sprintf(path, "cpuidle/state%d/time", state);
61976212

6213+
if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf))
6214+
continue;
6215+
61986216
if (is_deferred_skip(name_buf))
61996217
continue;
62006218

@@ -6220,6 +6238,9 @@ void probe_sysfs(void)
62206238

62216239
sprintf(path, "cpuidle/state%d/usage", state);
62226240

6241+
if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf))
6242+
continue;
6243+
62236244
if (is_deferred_skip(name_buf))
62246245
continue;
62256246

0 commit comments

Comments
 (0)