Skip to content

Commit ec4acd3

Browse files
committed
tools/power turbostat: disable "cpuidle" invocation counters, by default
Create "pct_idle" counter group, the sofware notion of residency so it can now be singled out, independent of other counter groups. Create "cpuidle" group, the cpuidle invocation counts. Disable "cpuidle", by default. Create "swidle" = "cpuidle" + "pct_idle". Undocument "sysfs", the old name for "swidle", but keep it working for backwards compatibilty. Create "hwidle", all the HW idle counters Modify "idle", enabled by default "idle" = "hwidle" + "pct_idle" (and now excludes "cpuidle") Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 9946338 commit ec4acd3

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

tools/power/x86/turbostat/turbostat.8

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ The column name "all" can be used to enable all disabled-by-default built-in cou
100100
.PP
101101
\fB--show column\fP show only the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names.
102102
.PP
103-
\fB--show CATEGORY --hide CATEGORY\fP Show and hide also accept a single CATEGORY of columns: "all", "topology", "idle", "frequency", "power", "sysfs", "other".
103+
\fB--show CATEGORY --hide CATEGORY\fP Show and hide also accept a single CATEGORY of columns: "all", "topology", "idle", "frequency", "power", "cpuidle", "hwidle", "swidle", "other". "idle" (enabled by default), includes "hwidle" and "idle_pct". "cpuidle" (default disabled) includes cpuidle software invocation counters. "swidle" includes "cpuidle" plus "idle_pct". "hwidle" includes only hardware based idle residency counters. Older versions of turbostat used the term "sysfs" for what is now "swidle".
104104
.PP
105105
\fB--Dump\fP displays the raw counter values.
106106
.PP
@@ -158,15 +158,15 @@ The system configuration dump (if --quiet is not used) is followed by statistics
158158
.PP
159159
\fBSMI\fP The number of System Management Interrupts serviced CPU during the measurement interval. While this counter is actually per-CPU, SMI are triggered on all processors, so the number should be the same for all CPUs.
160160
.PP
161-
\fBC1, C2, C3...\fP The number times Linux requested the C1, C2, C3 idle state during the measurement interval. The system summary line shows the sum for all CPUs. These are C-state names as exported in /sys/devices/system/cpu/cpu*/cpuidle/state*/name. While their names are generic, their attributes are processor specific. They the system description section of output shows what MWAIT sub-states they are mapped to on each system.
161+
\fBC1, C2, C3...\fP The number times Linux requested the C1, C2, C3 idle state during the measurement interval. The system summary line shows the sum for all CPUs. These are C-state names as exported in /sys/devices/system/cpu/cpu*/cpuidle/state*/name. While their names are generic, their attributes are processor specific. They the system description section of output shows what MWAIT sub-states they are mapped to on each system. These counters are in the "cpuidle" group, which is disabled, by default.
162162
.PP
163-
\fBC1+, C2+, C3+...\fP The idle governor idle state misprediction statistics. Inidcates the number times Linux requested the C1, C2, C3 idle state during the measurement interval, but should have requested a deeper idle state (if it exists and enabled). These statistics come from the /sys/devices/system/cpu/cpu*/cpuidle/state*/below file.
163+
\fBC1+, C2+, C3+...\fP The idle governor idle state misprediction statistics. Inidcates the number times Linux requested the C1, C2, C3 idle state during the measurement interval, but should have requested a deeper idle state (if it exists and enabled). These statistics come from the /sys/devices/system/cpu/cpu*/cpuidle/state*/below file. These counters are in the "cpuidle" group, which is disabled, by default.
164164
.PP
165-
\fBC1-, C2-, C3-...\fP The idle governor idle state misprediction statistics. Inidcates the number times Linux requested the C1, C2, C3 idle state during the measurement interval, but should have requested a shallower idle state (if it exists and enabled). These statistics come from the /sys/devices/system/cpu/cpu*/cpuidle/state*/above file.
165+
\fBC1-, C2-, C3-...\fP The idle governor idle state misprediction statistics. Inidcates the number times Linux requested the C1, C2, C3 idle state during the measurement interval, but should have requested a shallower idle state (if it exists and enabled). These statistics come from the /sys/devices/system/cpu/cpu*/cpuidle/state*/above file. These counters are in the "cpuidle" group, which is disabled, by default.
166166
.PP
167-
\fBC1%, C2%, C3%\fP The residency percentage that Linux requested C1, C2, C3.... The system summary is the average of all CPUs in the system. Note that these are software, reflecting what was requested. The hardware counters reflect what was actually achieved.
167+
\fBC1%, C2%, C3%\fP The residency percentage that Linux requested C1, C2, C3.... The system summary is the average of all CPUs in the system. Note that these are software, reflecting what was requested. The hardware counters reflect what was actually achieved. These counters are in the "pct_idle" group, which is enabled by default.
168168
.PP
169-
\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters.
169+
\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. These numbers are from hardware residency counters and are in the "hwidle" group, which is enabled, by default.
170170
.PP
171171
\fBCoreTmp\fP Degrees Celsius reported by the per-core Digital Thermal Sensor.
172172
.PP

tools/power/x86/turbostat/turbostat.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct msr_counter bic[] = {
153153
{ 0x0, "TSC_MHz", NULL, 0, 0, 0, NULL, 0 },
154154
{ 0x0, "IRQ", NULL, 0, 0, 0, NULL, 0 },
155155
{ 0x0, "SMI", NULL, 32, 0, FORMAT_DELTA, NULL, 0 },
156-
{ 0x0, "sysfs", NULL, 0, 0, 0, NULL, 0 },
156+
{ 0x0, "cpuidle", NULL, 0, 0, 0, NULL, 0 },
157157
{ 0x0, "CPU%c1", NULL, 0, 0, 0, NULL, 0 },
158158
{ 0x0, "CPU%c3", NULL, 0, 0, 0, NULL, 0 },
159159
{ 0x0, "CPU%c6", NULL, 0, 0, 0, NULL, 0 },
@@ -206,6 +206,7 @@ struct msr_counter bic[] = {
206206
{ 0x0, "Sys_J", NULL, 0, 0, 0, NULL, 0 },
207207
{ 0x0, "NMI", NULL, 0, 0, 0, NULL, 0 },
208208
{ 0x0, "CPU%c1e", NULL, 0, 0, 0, NULL, 0 },
209+
{ 0x0, "pct_idle", NULL, 0, 0, 0, NULL, 0 },
209210
};
210211

211212
#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
@@ -219,7 +220,7 @@ struct msr_counter bic[] = {
219220
#define BIC_TSC_MHz (1ULL << 7)
220221
#define BIC_IRQ (1ULL << 8)
221222
#define BIC_SMI (1ULL << 9)
222-
#define BIC_sysfs (1ULL << 10)
223+
#define BIC_cpuidle (1ULL << 10)
223224
#define BIC_CPU_c1 (1ULL << 11)
224225
#define BIC_CPU_c3 (1ULL << 12)
225226
#define BIC_CPU_c6 (1ULL << 13)
@@ -272,17 +273,20 @@ struct msr_counter bic[] = {
272273
#define BIC_Sys_J (1ULL << 60)
273274
#define BIC_NMI (1ULL << 61)
274275
#define BIC_CPU_c1e (1ULL << 62)
276+
#define BIC_pct_idle (1ULL << 63)
275277

276278
#define BIC_GROUP_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
277279
#define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
278280
#define BIC_GROUP_FREQUENCY (BIC_Avg_MHz | BIC_Busy | BIC_Bzy_MHz | BIC_TSC_MHz | BIC_GFXMHz | BIC_GFXACTMHz | BIC_SAMMHz | BIC_SAMACTMHz | BIC_UNCORE_MHZ)
279-
#define BIC_GROUP_IDLE (BIC_Busy | BIC_sysfs | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)
281+
#define BIC_GROUP_HW_IDLE (BIC_Busy | BIC_CPU_c1 | BIC_CPU_c3 | BIC_CPU_c6 | BIC_CPU_c7 | BIC_GFX_rc6 | BIC_Pkgpc2 | BIC_Pkgpc3 | BIC_Pkgpc6 | BIC_Pkgpc7 | BIC_Pkgpc8 | BIC_Pkgpc9 | BIC_Pkgpc10 | BIC_CPU_LPI | BIC_SYS_LPI | BIC_Mod_c6 | BIC_Totl_c0 | BIC_Any_c0 | BIC_GFX_c0 | BIC_CPUGFX | BIC_SAM_mc6 | BIC_Diec6)
282+
#define BIC_GROUP_SW_IDLE (BIC_Busy | BIC_cpuidle | BIC_pct_idle )
283+
#define BIC_GROUP_IDLE (BIC_GROUP_HW_IDLE | BIC_pct_idle)
280284
#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
281285

282-
#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC)
286+
#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC | BIC_cpuidle)
283287

284288
unsigned long long bic_enabled = (0xFFFFFFFFFFFFFFFFULL & ~BIC_DISABLED_BY_DEFAULT);
285-
unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_sysfs | BIC_APIC | BIC_X2APIC;
289+
unsigned long long bic_present = BIC_USEC | BIC_TOD | BIC_cpuidle | BIC_pct_idle | BIC_APIC | BIC_X2APIC;
286290

287291
#define DO_BIC(COUNTER_NAME) (bic_enabled & bic_present & COUNTER_NAME)
288292
#define DO_BIC_READ(COUNTER_NAME) (bic_present & COUNTER_NAME)
@@ -2362,6 +2366,15 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
23622366
} else if (!strcmp(name_list, "idle")) {
23632367
retval |= BIC_GROUP_IDLE;
23642368
break;
2369+
} else if (!strcmp(name_list, "swidle")) {
2370+
retval |= BIC_GROUP_SW_IDLE;
2371+
break;
2372+
} else if (!strcmp(name_list, "sysfs")) { /* legacy compatibility */
2373+
retval |= BIC_GROUP_SW_IDLE;
2374+
break;
2375+
} else if (!strcmp(name_list, "hwidle")) {
2376+
retval |= BIC_GROUP_HW_IDLE;
2377+
break;
23652378
} else if (!strcmp(name_list, "frequency")) {
23662379
retval |= BIC_GROUP_FREQUENCY;
23672380
break;
@@ -2372,6 +2385,7 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
23722385

23732386
}
23742387
if (i == MAX_BIC) {
2388+
fprintf(stderr, "deferred %s\n", name_list);
23752389
if (mode == SHOW_LIST) {
23762390
deferred_add_names[deferred_add_index++] = name_list;
23772391
if (deferred_add_index >= MAX_DEFERRED) {
@@ -10269,6 +10283,9 @@ void probe_cpuidle_residency(void)
1026910283
int min_state = 1024, max_state = 0;
1027010284
char *sp;
1027110285

10286+
if (!DO_BIC(BIC_pct_idle))
10287+
return;
10288+
1027210289
for (state = 10; state >= 0; --state) {
1027310290

1027410291
sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name", base_cpu, state);
@@ -10291,7 +10308,7 @@ void probe_cpuidle_residency(void)
1029110308

1029210309
sprintf(path, "cpuidle/state%d/time", state);
1029310310

10294-
if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf))
10311+
if (!DO_BIC(BIC_pct_idle) && !is_deferred_add(name_buf))
1029510312
continue;
1029610313

1029710314
if (is_deferred_skip(name_buf))
@@ -10315,6 +10332,9 @@ void probe_cpuidle_counts(void)
1031510332
int min_state = 1024, max_state = 0;
1031610333
char *sp;
1031710334

10335+
if (!DO_BIC(BIC_cpuidle))
10336+
return;
10337+
1031810338
for (state = 10; state >= 0; --state) {
1031910339

1032010340
sprintf(path, "/sys/devices/system/cpu/cpu%d/cpuidle/state%d/name", base_cpu, state);
@@ -10327,7 +10347,7 @@ void probe_cpuidle_counts(void)
1032710347

1032810348
remove_underbar(name_buf);
1032910349

10330-
if (!DO_BIC(BIC_sysfs) && !is_deferred_add(name_buf))
10350+
if (!DO_BIC(BIC_cpuidle) && !is_deferred_add(name_buf))
1033110351
continue;
1033210352

1033310353
if (is_deferred_skip(name_buf))

0 commit comments

Comments
 (0)