Skip to content

Commit a80e534

Browse files
committed
tools/power turbostat: version 2025.01.14
Fix checkpatch whitespace issues since 2024.11.30 Summary of Changes since 2024.11.30: Enable SysWatt by default. Add initial PTL, CWF platform support. Refuse to run on unsupported platforms without --force to avoid not-so-useful measurements mistakenly made using obsolete versions. Harden initial PMT code in response to early use. Signed-off-by: Len Brown <[email protected]>
1 parent 83fbeb9 commit a80e534

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

Diff for: tools/power/x86/turbostat/turbostat.c

+16-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* turbostat -- show CPU frequency and C-state residency
44
* on modern Intel and AMD processors.
55
*
6-
* Copyright (c) 2024 Intel Corporation.
6+
* Copyright (c) 2025 Intel Corporation.
77
* Len Brown <[email protected]>
88
*/
99

@@ -271,11 +271,11 @@ struct msr_counter bic[] = {
271271
#define BIC_Sys_J (1ULL << 60)
272272
#define BIC_NMI (1ULL << 61)
273273

274-
#define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die )
275-
#define BIC_THERMAL_PWR ( BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
274+
#define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
275+
#define BIC_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
276276
#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)
277277
#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)
278-
#define BIC_OTHER ( BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
278+
#define BIC_OTHER (BIC_IRQ | BIC_NMI | BIC_SMI | BIC_ThreadC | BIC_CoreTmp | BIC_IPC)
279279

280280
#define BIC_DISABLED_BY_DEFAULT (BIC_USEC | BIC_TOD | BIC_APIC | BIC_X2APIC)
281281

@@ -1593,8 +1593,7 @@ struct pmt_counter {
15931593
* PMT telemetry directory iterator.
15941594
* Used to iterate telemetry files in sysfs in correct order.
15951595
*/
1596-
struct pmt_diriter_t
1597-
{
1596+
struct pmt_diriter_t {
15981597
DIR *dir;
15991598
struct dirent **namelist;
16001599
unsigned int num_names;
@@ -1604,6 +1603,7 @@ struct pmt_diriter_t
16041603
int pmt_telemdir_filter(const struct dirent *e)
16051604
{
16061605
unsigned int dummy;
1606+
16071607
return sscanf(e->d_name, "telem%u", &dummy);
16081608
}
16091609

@@ -1617,7 +1617,7 @@ int pmt_telemdir_sort(const struct dirent **a, const struct dirent **b)
16171617
return aidx >= bidx;
16181618
}
16191619

1620-
const struct dirent* pmt_diriter_next(struct pmt_diriter_t *iter)
1620+
const struct dirent *pmt_diriter_next(struct pmt_diriter_t *iter)
16211621
{
16221622
const struct dirent *ret = NULL;
16231623

@@ -1633,7 +1633,7 @@ const struct dirent* pmt_diriter_next(struct pmt_diriter_t *iter)
16331633
return ret;
16341634
}
16351635

1636-
const struct dirent* pmt_diriter_begin(struct pmt_diriter_t *iter, const char *pmt_root_path)
1636+
const struct dirent *pmt_diriter_begin(struct pmt_diriter_t *iter, const char *pmt_root_path)
16371637
{
16381638
int num_names = iter->num_names;
16391639

@@ -2302,7 +2302,7 @@ void help(void)
23022302
" -h, --help\n"
23032303
" print this help message\n"
23042304
" -v, --version\n"
2305-
" print version information\n" "\n" "For more help, run \"man turbostat\"\n");
2305+
" print version information\n\nFor more help, run \"man turbostat\"\n");
23062306
}
23072307

23082308
/*
@@ -9053,18 +9053,16 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)
90539053
return NULL;
90549054
}
90559055

9056-
for (;entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {
9057-
if (fstatat(dirfd(pmt_iter.dir), entry->d_name, &st, 0) == -1) {
9056+
for ( ; entry != NULL; entry = pmt_diriter_next(&pmt_iter)) {
9057+
if (fstatat(dirfd(pmt_iter.dir), entry->d_name, &st, 0) == -1)
90589058
break;
9059-
}
90609059

90619060
if (!S_ISDIR(st.st_mode))
90629061
continue;
90639062

90649063
fd_telem_dir = openat(dirfd(pmt_iter.dir), entry->d_name, O_RDONLY);
9065-
if (fd_telem_dir == -1) {
9064+
if (fd_telem_dir == -1)
90669065
break;
9067-
}
90689066

90699067
if (parse_telem_info_file(fd_telem_dir, "guid", "%lx", &guid)) {
90709068
close(fd_telem_dir);
@@ -9425,7 +9423,7 @@ int get_and_dump_counters(void)
94259423

94269424
void print_version()
94279425
{
9428-
fprintf(outf, "turbostat version 2024.11.30 - Len Brown <[email protected]>\n");
9426+
fprintf(outf, "turbostat version 2025.01.14 - Len Brown <[email protected]>\n");
94299427
}
94309428

94319429
#define COMMAND_LINE_SIZE 2048
@@ -9750,7 +9748,7 @@ void parse_add_command_msr(char *add_command)
97509748

97519749
}
97529750
if ((msr_num == 0) && (path == NULL) && (perf_device[0] == '\0' || perf_event[0] == '\0')) {
9753-
fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter | perf/device/event ) required\n");
9751+
fprintf(stderr, "--add: (msrDDD | msr0xXXX | /path_to_counter | perf/device/event) required\n");
97549752
fail++;
97559753
}
97569754

@@ -9822,9 +9820,8 @@ int pmt_parse_from_path(const char *target_path, unsigned int *out_guid, unsigne
98229820
dirname = pmt_diriter_next(&pmt_iter)) {
98239821

98249822
fd_telem_dir = openat(dirfd(pmt_iter.dir), dirname->d_name, O_RDONLY | O_DIRECTORY);
9825-
if (fd_telem_dir == -1) {
9823+
if (fd_telem_dir == -1)
98269824
continue;
9827-
}
98289825

98299826
if (parse_telem_info_file(fd_telem_dir, "guid", "%lx", &guid)) {
98309827
fprintf(stderr, "%s: Failed to parse the guid file: %s", __func__, strerror(errno));
@@ -9962,9 +9959,8 @@ void parse_add_command_pmt(char *add_command)
99629959
goto next;
99639960
}
99649961

9965-
if (sscanf(add_command, "seq=%x", &seq) == 1) {
9962+
if (sscanf(add_command, "seq=%x", &seq) == 1)
99669963
goto next;
9967-
}
99689964

99699965
if (strncmp(add_command, direct_path_prefix, strlen(direct_path_prefix)) == 0) {
99709966
direct_path = add_command + strlen(direct_path_prefix);

0 commit comments

Comments
 (0)