Skip to content

Commit 9946338

Browse files
committed
tools/power turbostat: re-factor sysfs code
Probe cpuidle "sysfs" residency and counts separately, since soon we will make one disabled on, and the other disabled off. Clarify that some BIC (build-in-counters) are actually "groups". since we're about to re-name some of those groups. no functional change. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent f8b136e commit 9946338

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ struct msr_counter bic[] = {
273273
#define BIC_NMI (1ULL << 61)
274274
#define BIC_CPU_c1e (1ULL << 62)
275275

276-
#define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
277-
#define BIC_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
278-
#define BIC_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_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)
276+
#define BIC_GROUP_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
277+
#define BIC_GROUP_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
278+
#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)
280280
#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
281281

282282
#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC)
@@ -2354,16 +2354,16 @@ unsigned long long bic_lookup(char *name_list, enum show_hide_mode mode)
23542354
retval |= ~0;
23552355
break;
23562356
} else if (!strcmp(name_list, "topology")) {
2357-
retval |= BIC_TOPOLOGY;
2357+
retval |= BIC_GROUP_TOPOLOGY;
23582358
break;
23592359
} else if (!strcmp(name_list, "power")) {
2360-
retval |= BIC_THERMAL_PWR;
2360+
retval |= BIC_GROUP_THERMAL_PWR;
23612361
break;
23622362
} else if (!strcmp(name_list, "idle")) {
2363-
retval |= BIC_IDLE;
2363+
retval |= BIC_GROUP_IDLE;
23642364
break;
23652365
} else if (!strcmp(name_list, "frequency")) {
2366-
retval |= BIC_FREQUENCY;
2366+
retval |= BIC_GROUP_FREQUENCY;
23672367
break;
23682368
} else if (!strcmp(name_list, "other")) {
23692369
retval |= BIC_OTHER;
@@ -10260,7 +10260,7 @@ int is_deferred_skip(char *name)
1026010260
return 0;
1026110261
}
1026210262

10263-
void probe_sysfs(void)
10263+
void probe_cpuidle_residency(void)
1026410264
{
1026510265
char path[64];
1026610266
char name_buf[16];
@@ -10304,6 +10304,16 @@ void probe_sysfs(void)
1030410304
if (state < min_state)
1030510305
min_state = state;
1030610306
}
10307+
}
10308+
10309+
void probe_cpuidle_counts(void)
10310+
{
10311+
char path[64];
10312+
char name_buf[16];
10313+
FILE *input;
10314+
int state;
10315+
int min_state = 1024, max_state = 0;
10316+
char *sp;
1030710317

1030810318
for (state = 10; state >= 0; --state) {
1030910319

@@ -10602,7 +10612,8 @@ int main(int argc, char **argv)
1060210612
print_bootcmd();
1060310613
}
1060410614

10605-
probe_sysfs();
10615+
probe_cpuidle_residency();
10616+
probe_cpuidle_counts();
1060610617

1060710618
if (!getuid())
1060810619
set_rlimit();

0 commit comments

Comments
 (0)