turbostat-v2025.12.02 x86_energy_policy-v2025.11.22
Len Brown
maintainercover turbostat-v2025.12.02 x86_energy_policy-v2025.11.22
This patch series is staged for upstream in my public git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux.git turbostat
In summary, since turbostat-v2025.09.09:
Add LLC statistics columns:
LLCkRPS = Last Level Cache Thousands of References Per Second LLC%hit = Last Level Cache Hit %
Recognize Wildcat Lake and Nova Lake platforms
Add MSR check for Android
Add APERF check for VMWARE
Add RAPL check for AWS
minor fixes to turbostat and x86_energy_perf_policy
Please let me know if you see any issues.
thanks!
-Len Brown, Intel Open Source Technology Center
----------------------------------------------------------------
Emily Ehlert (1):
tools/power turbostat: Set per_cpu_msr_sum to NULL after free
Kaushlendra Kumar (1):
tools/power x86_energy_perf_policy: Add Android MSR device support
Len Brown (17):
tools/power turbostat: Regression fix Uncore MHz printed in hex tools/power turbostat: Add Wildcat Lake and Nova Lake support tools/power turbostat: Refactor added column header printing tools/power turbostat: Refactor added-counter value printing code tools/power turbostat.8: Update example
tools/power turbostat: Refactor floating point printout code tools/power turbostat: Remove dead code
tools/power turbostat: Add LLC stats
tools/power turbostat: Add run-time MSR driver probe tools/power x86_energy_perf_policy: Simplify Android MSR probe tools/power turbostat: Validate RAPL MSRs for AWS Nitro Hypervisor tools/power turbostat: Enhance perf probe
tools/power turbostat: Validate APERF access for VMWARE tools/power turbostat: Print "nan" for out of range percentages tools/power turbostat: Print percentages in 8-columns tools/power turbostat: Print wide names only for RAW 64-bit columns tools/power turbostat: version 2025.12.02
Malaya Kumar Rout (2):
tools/power x86_energy_perf_policy: Fix format string in error message tools/power x86_energy_perf_policy: Fix potential NULL pointer dereference
tools/power/x86/turbostat/turbostat.8 | 27 +- tools/power/x86/turbostat/turbostat.c | 1205 ++++++++++---------- .../x86_energy_perf_policy.c | 47 +- 3 files changed, 660 insertions(+), 619 deletions(-)
Len Brown
maintainerPATCH 1/21 tools/power turbostat: Regression fix Uncore MHz printed in hex
From: Len Brown <[email protected]>
A patch to allow specifying FORMAT_AVERAGE to added counters... broke the internally added counter for Cluster Uncore MHz -- printing it in HEX.
--- tools/power/x86/turbostat/turbostat.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/power/x86/turbostat/turbostat.c +6 -6
@@ -3285,13 +3285,13 @@ int format_counters(PER_THREAD_PARAMS)/* Added counters */ for (i =0 , mp = sys.tp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { +if (mp->format ==FORMAT_RAW ) {if (mp->width ==32 ) outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )t->counter[i]);else outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), t->counter[i]); - }else if (mp->format ==FORMAT_DELTA ) { + }else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) {if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), t->counter[i]);else
@@ -3382,13 +3382,13 @@ int format_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), c->core_throt_cnt);for (i =0 , mp = sys.cp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { +if (mp->format ==FORMAT_RAW ) {if (mp->width ==32 ) outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )c->counter[i]);else outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), c->counter[i]); - }else if (mp->format ==FORMAT_DELTA ) { + }else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) {if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), c->counter[i]);else
@@ -3581,7 +3581,7 @@ int format_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), p->uncore_mhz);for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { +if (mp->format ==FORMAT_RAW ) {if (mp->width ==32 ) outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )p->counter[i]);
@@ -3758,7 +3758,7 @@ int delta_package(struct pkg_data *new, struct pkg_data *old) new->rapl_dram_perf_status.raw_value - old->rapl_dram_perf_status.raw_value;for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) +if (mp->format ==FORMAT_RAW ) old->counter[i] = new->counter[i];else if (mp->format ==FORMAT_AVERAGE ) old->counter[i] = new->counter[i];
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 2/21 tools/power turbostat: Add Wildcat Lake and Nova Lake support
From: Len Brown <[email protected]>
Treat Wildcat Lake and Nova Lake (and Panther Lake) the same as Lunar Lake, for now.
--- tools/power/x86/turbostat/turbostat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +4 -1
@@ -1210,6 +1210,9 @@ static const struct platform_data turbostat_pdata[] = { { INTEL_ARROWLAKE, &adl_features }, { INTEL_LUNARLAKE_M, &lnl_features }, { INTEL_PANTHERLAKE_L, &lnl_features }, + { INTEL_NOVALAKE, &lnl_features }, + { INTEL_NOVALAKE_L, &lnl_features }, + { INTEL_WILDCATLAKE_L, &lnl_features }, { INTEL_ATOM_SILVERMONT, &slv_features }, { INTEL_ATOM_SILVERMONT_D, &slvd_features }, { INTEL_ATOM_AIRMONT, &amt_features },
@@ -10126,7 +10129,7 @@ int get_and_dump_counters(void)void print_version () { -fprintf (outf,"turbostat version 2025.09.09 - Len Brown <[email protected]>\n" ); +fprintf (outf,"turbostat version 2025.10.18 - Len Brown <[email protected]>\n" ); }#define COMMAND_LINE_SIZE 2048
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 3/21 tools/power turbostat: Refactor added column header printing
In reply to Len BrownFrom: Len Brown <[email protected]>
Over time, we built up many copies of nearly identical code...
--- tools/power/x86/turbostat/turbostat.c | 137 +++++++------------------- 1 file changed, 36 insertions(+), 101 deletions(-)
tools/power/x86/turbostat/turbostat.c +36 -101
@@ -2705,6 +2705,24 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode) } } +/* +* print_name() +* Print column header name for 64-bit counter in 16 columns (at least 8-char plus a tab) +* Otherwise, allow the name + tab to fit within 8-coumn tab-stop. +* In both cases, left justififed, just like other turbostat columns, +* to allow the column values to consume the tab. +* +* Yes, 32-bit counters can overflow 8-columns, but then they are usually 64-bit counters. +* 64-bit counters can overflow 16-columns, but rarely do. +*/ +static inline int print_name (int width,int *printed,char *delim,char *name) +{ +if (width ==64 ) +return (sprintf (outp,"%s%-8s" , (*printed++ ? delim :"" ), name)); +else +return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); +} +void print_header (char *delim) {struct msr_counter *mp;
@@ -2760,50 +2778,22 @@ void print_header(char *delim)if (DO_BIC (BIC_SMI )) outp +=sprintf (outp,"%sSMI" , (printed++ ? delim :"" )); -for (mp = sys.tp; mp; mp = mp->next) { +for (mp = sys.tp; mp; mp = mp->next) + outp +=print_name (mp->width, &printed, delim, mp->name); -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { -if (mp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), mp->name); -else - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), mp->name); - }else { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , (printed++ ? delim :"" ), mp->name); -else - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), mp->name); - } - } - -for (pp = sys.perf_tp; pp; pp = pp->next) { - -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), pp->name); - }else { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), pp->name); - } - } +for (pp = sys.perf_tp; pp; pp = pp->next) + outp +=print_name (pp->width, &printed, delim, pp->name); ppmt = sys.pmt_tp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), ppmt->name); -else - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), ppmt->name); - + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name);break ; }
@@ -2836,49 +2826,23 @@ void print_header(char *delim) outp +=sprintf (outp,"%sCor_J" , (printed++ ? delim :"" )); } -for (mp = sys.cp; mp; mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { -if (mp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , delim, mp->name); -else - outp +=sprintf (outp,"%s%10.10s" , delim, mp->name); - }else { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , delim, mp->name); -else - outp +=sprintf (outp,"%s%s" , delim, mp->name); - } - } - -for (pp = sys.perf_cp; pp; pp = pp->next) { +for (mp = sys.cp; mp; mp = mp->next) + outp +=print_name (mp->width, &printed, delim, mp->name); -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), pp->name); - }else { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), pp->name); - } - } +for (pp = sys.perf_cp; pp; pp = pp->next) + outp +=print_name (pp->width, &printed, delim, pp->name); ppmt = sys.pmt_cp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), ppmt->name); -else - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), ppmt->name); + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name);break ; }
@@ -2966,51 +2930,22 @@ void print_header(char *delim)if (DO_BIC (BIC_UNCORE_MHZ )) outp +=sprintf (outp,"%sUncMHz" , (printed++ ? delim :"" )); -for (mp = sys.pp; mp; mp = mp->next) { -if (mp->format ==FORMAT_RAW || mp->format ==FORMAT_AVERAGE ) { -if (mp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , delim, mp->name); -else if (mp->width ==32 ) - outp +=sprintf (outp,"%s%10.10s" , delim, mp->name); -else - outp +=sprintf (outp,"%s%7.7s" , delim, mp->name); - }else { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , delim, mp->name); -else - outp +=sprintf (outp,"%s%7.7s" , delim, mp->name); - } - } - -for (pp = sys.perf_pp; pp; pp = pp->next) { +for (mp = sys.pp; mp; mp = mp->next) + outp +=print_name (mp->width, &printed, delim, mp->name); -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==64 ) - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), pp->name); - }else { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8s" , (printed++ ? delim :"" ), pp->name); -else - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), pp->name); - } - } +for (pp = sys.perf_pp; pp; pp = pp->next) + outp +=print_name (pp->width, &printed, delim, pp->name); ppmt = sys.pmt_pp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s%10.10s" , (printed++ ? delim :"" ), ppmt->name); -else - outp +=sprintf (outp,"%s%18.18s" , (printed++ ? delim :"" ), ppmt->name); - + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=sprintf (outp,"%s%s" , (printed++ ? delim :"" ), ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name);break ; }
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 4/21 tools/power turbostat: Refactor added-counter value printing code
In reply to Len BrownFrom: Len Brown <[email protected]>
We build up many copies of very similar code...
--- tools/power/x86/turbostat/turbostat.c | 153 ++++++++++---------------- 1 file changed, 57 insertions(+), 96 deletions(-)
tools/power/x86/turbostat/turbostat.c +57 -96
@@ -2717,10 +2717,24 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)*/ static inline int print_name (int width,int *printed,char *delim,char *name) { -if (width ==64 ) +if (width <=32 ) +return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); +else return (sprintf (outp,"%s%-8s" , (*printed++ ? delim :"" ), name)); +} +static inline int print_hex_value (int width,int *printed,char *delim,unsigned long long value) +{ +if (width <=32 ) +return (sprintf (outp,"%s%08x" , (*printed++ ? delim :"" ), (unsigned int )value));else -return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); +return (sprintf (outp,"%s%016llx" , (*printed++ ? delim :"" ), value)); +} +static inline int print_decimal_value (int width,int *printed,char *delim,unsigned long long value) +{ +if (width <=32 ) +return (sprintf (outp,"%s%d" , (*printed++ ? delim :"" ), (unsigned int )value)); +else +return (sprintf (outp,"%s%-8lld" , (*printed++ ? delim :"" ), value)); }void print_header (char *delim)
@@ -3221,20 +3235,13 @@ int format_counters(PER_THREAD_PARAMS)if (DO_BIC (BIC_SMI )) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), t->smi_count); -/* Added counters */ +/* Added Thread Counters */ for (i =0 , mp = sys.tp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW ) { -if (mp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )t->counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), t->counter[i]); - }else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), t->counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), t->counter[i]); - }else if (mp->format ==FORMAT_PERCENT ) { +if (mp->format ==FORMAT_RAW ) + outp +=print_hex_value (mp->width, &printed, delim, t->counter[i]); +else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) + outp +=print_decimal_value (mp->width, &printed, delim, t->counter[i]); +else if (mp->format ==FORMAT_PERCENT ) {if (mp->type ==COUNTER_USEC ) outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""),
@@ -3244,21 +3251,13 @@ int format_counters(PER_THREAD_PARAMS) } } -/* Added perf counters */ +/* Added perf Thread Counters */ for (i =0 , pp = sys.perf_tp; pp; ++i, pp = pp->next) { -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )t->perf_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), t->perf_counter[i]); - }else if (pp->format ==FORMAT_DELTA ) { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), t->perf_counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), t->perf_counter[i]); - }else if (pp->format ==FORMAT_PERCENT ) { +if (pp->format ==FORMAT_RAW ) + outp +=print_hex_value (pp->width, &printed, delim, t->perf_counter[i]); +else if (pp->format ==FORMAT_DELTA ) + outp +=print_decimal_value (pp->width, &printed, delim, t->perf_counter[i]); +else if (pp->format ==FORMAT_PERCENT ) {if (pp->type ==COUNTER_USEC ) outp += sprintf(outp, "%s%.2f", (printed++ ? delim : ""),
@@ -3269,17 +3268,13 @@ int format_counters(PER_THREAD_PARAMS) } } +/* Added PMT Thread Counters */ for (i =0 , ppmt = sys.pmt_tp; ppmt; i++, ppmt = ppmt->next) {const unsigned long value_raw = t->pmt_counter[i];double value_converted;switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )t->pmt_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), t->pmt_counter[i]); - + outp +=print_hex_value (pmt_counter_get_width (ppmt), &printed, delim, t->pmt_counter[i]);break ;case PMT_TYPE_XTAL_TIME :
@@ -3319,52 +3314,35 @@ int format_counters(PER_THREAD_PARAMS)if (DO_BIC (BIC_CORE_THROT_CNT )) outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), c->core_throt_cnt); +/* Added Core Counters */ for (i =0 , mp = sys.cp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW ) { -if (mp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )c->counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), c->counter[i]); - }else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), c->counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), c->counter[i]); - }else if (mp->format ==FORMAT_PERCENT ) { +if (mp->format ==FORMAT_RAW ) + outp +=print_hex_value (mp->width, &printed, delim, c->counter[i]); +else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) + outp +=print_decimal_value (mp->width, &printed, delim, c->counter[i]); +else if (mp->format ==FORMAT_PERCENT ) { outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->counter[i] / tsc); } } +/* Added perf Core counters */ for (i =0 , pp = sys.perf_cp; pp; i++, pp = pp->next) { -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )c->perf_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), c->perf_counter[i]); - }else if (pp->format ==FORMAT_DELTA ) { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), c->perf_counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), c->perf_counter[i]); - }else if (pp->format ==FORMAT_PERCENT ) { +if (pp->format ==FORMAT_RAW ) + outp +=print_hex_value (pp->width, &printed, delim, c->perf_counter[i]); +else if (pp->format ==FORMAT_DELTA ) + outp +=print_decimal_value (pp->width, &printed, delim, c->perf_counter[i]); +else if (pp->format ==FORMAT_PERCENT ) { outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->perf_counter[i] / tsc); } } +/* Added PMT Core counters */ for (i =0 , ppmt = sys.pmt_cp; ppmt; i++, ppmt = ppmt->next) {const unsigned long value_raw = c->pmt_counter[i];double value_converted;switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )c->pmt_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), c->pmt_counter[i]); - + outp +=print_hex_value (pmt_counter_get_width (ppmt), &printed, delim, c->pmt_counter[i]);break ;case PMT_TYPE_XTAL_TIME :
@@ -3518,37 +3496,24 @@ int format_counters(PER_THREAD_PARAMS)if (DO_BIC (BIC_UNCORE_MHZ )) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), p->uncore_mhz); +/* Added Package Counters */ for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) { -if (mp->format ==FORMAT_RAW ) { -if (mp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), (unsigned int )p->counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), p->counter[i]); - }else if (mp->format ==FORMAT_DELTA ) { -if ((mp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), p->counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), p->counter[i]); - }else if (mp->format ==FORMAT_PERCENT ) { +if (mp->format ==FORMAT_RAW ) + outp +=print_hex_value (mp->width, &printed, delim, p->counter[i]); +else if (mp->format ==FORMAT_DELTA ) + outp +=print_decimal_value (mp->width, &printed, delim, p->counter[i]); +else if (mp->format ==FORMAT_PERCENT ) { outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->counter[i] / tsc); }else if (mp->type ==COUNTER_K2M ) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), (unsigned int )p->counter[i] /1000 ); } +/* Added perf Package Counters */ for (i =0 , pp = sys.perf_pp; pp; i++, pp = pp->next) { -if (pp->format ==FORMAT_RAW ) { -if (pp->width ==32 ) - outp += -sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )p->perf_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), p->perf_counter[i]); - }else if (pp->format ==FORMAT_DELTA ) { -if ((pp->type ==COUNTER_ITEMS ) && sums_need_wide_columns) - outp +=sprintf (outp,"%s%8lld" , (printed++ ? delim :"" ), p->perf_counter[i]); -else - outp +=sprintf (outp,"%s%lld" , (printed++ ? delim :"" ), p->perf_counter[i]); +if (pp->format ==FORMAT_RAW ) + outp +=print_hex_value (pp->width, &printed, delim, p->perf_counter[i]); +else if (pp->format ==FORMAT_DELTA ) { + outp +=print_decimal_value (pp->width, &printed, delim, p->perf_counter[i]); }else if (pp->format ==FORMAT_PERCENT ) { outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->perf_counter[i] / tsc); }else if (pp->type ==COUNTER_K2M ) {
@@ -3557,17 +3522,13 @@ int format_counters(PER_THREAD_PARAMS) } } +/* Added PMT Package Counters */ for (i =0 , ppmt = sys.pmt_pp; ppmt; i++, ppmt = ppmt->next) {const unsigned long value_raw = p->pmt_counter[i];double value_converted;switch (ppmt->type) {case PMT_TYPE_RAW : -if (pmt_counter_get_width (ppmt) <=32 ) - outp +=sprintf (outp,"%s0x%08x" , (printed++ ? delim :"" ), - (unsigned int )p->pmt_counter[i]); -else - outp +=sprintf (outp,"%s0x%016llx" , (printed++ ? delim :"" ), p->pmt_counter[i]); - + outp +=print_hex_value (pmt_counter_get_width (ppmt), &printed, delim, p->pmt_counter[i]);break ;case PMT_TYPE_XTAL_TIME :
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 5/21 tools/power turbostat.8: Update example
In reply to Len BrownFrom: Len Brown <[email protected]>
Update the added-counters example to print counters in decimal rather than hex -- now that it is working...
--- tools/power/x86/turbostat/turbostat.8 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
tools/power/x86/turbostat/turbostat.8 +10 -11
@@ -410,25 +410,24 @@ CPU pCPU%c1 CPU%c1 .fi .SH ADD PERF COUNTER EXAMPLE #2 (using virtual cpu device) -Here we run on hybrid, Raptor Lake platform. -We limit turbostat to show output for just cpu0 (pcore) and cpu12 (ecore). +Here we run on hybrid, Meteor Lake platform. +We limit turbostat to show output for just cpu0 (pcore) and cpu4 (ecore). We add a counter showing number of L3 cache misses, using virtual "cpu" device, labeling it with the column header, "VCMISS". We add a counter showing number of L3 cache misses, using virtual "cpu_core" device, -labeling it with the column header, "PCMISS". This will fail on ecore cpu12. +labeling it with the column header, "PCMISS". This will fail on ecore cpu4. We add a counter showing number of L3 cache misses, using virtual "cpu_atom" device, labeling it with the column header, "ECMISS". This will fail on pcore cpu0. We display it only once, after the conclusion of 0.1 second sleep. .nf -sudo ./turbostat --quiet --cpu 0,12 --show CPU --add perf/cpu/cache-misses,cpu,delta,raw,VCMISS --add perf/cpu_core/cache-misses,cpu,delta,raw,PCMISS --add perf/cpu_atom/cache-misses,cpu,delta,raw,ECMISS sleep .1 +sudo ./turbostat --quiet --cpu 0,4 --show CPU --add perf/cpu/cache-misses,cpu,delta,VCMISS --add perf/cpu_core/cache-misses,cpu,delta,PCMISS --add perf/cpu_atom/cache-misses,cpu,delta,ECMISS sleep 5 turbostat: added_perf_counters_init_: perf/cpu_atom/cache-misses: failed to open counter on cpu0 -turbostat: added_perf_counters_init_: perf/cpu_core/cache-misses: failed to open counter on cpu12 -0.104630 sec -CPU ECMISS PCMISS VCMISS -- 0x0000000000000000 0x0000000000000000 0x0000000000000000 -0 0x0000000000000000 0x0000000000007951 0x0000000000007796 -12 0x000000000001137a 0x0000000000000000 0x0000000000011392 - +turbostat: added_perf_counters_init_: perf/cpu_core/cache-misses: failed to open counter on cpu4 +5.001207 sec +CPU ECMISS PCMISS VCMISS +- 41586506 46291219 87877749 +4 83173012 0 83173040 +0 0 92582439 92582458 .fi .SH ADD PMT COUNTER EXAMPLE
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 6/21 tools/power turbostat: Refactor floating point printout code
In reply to Len BrownFrom: Len Brown <[email protected]>
Too many copies of (usually) the same printf code...
Also, unify code for added-counter FORMAT_AVERAGE, which was correct where it was tested, but neglected elsewhere.
--- tools/power/x86/turbostat/turbostat.c | 60 +++++++++++++-------------- 1 file changed, 28 insertions(+), 32 deletions(-)
tools/power/x86/turbostat/turbostat.c +28 -32
@@ -2736,6 +2736,10 @@ static inline int print_decimal_value(int width, int *printed, char *delim, unsielse return (sprintf (outp,"%s%-8lld" , (*printed++ ? delim :"" ), value)); } +static inline int print_float_value (int *printed,char *delim,double value) +{ +return (sprintf (outp,"%s%0.2f" , (*printed++ ? delim :"" ), value)); +}void print_header (char *delim) {
@@ -3243,11 +3247,9 @@ int format_counters(PER_THREAD_PARAMS) outp +=print_decimal_value (mp->width, &printed, delim, t->counter[i]); else if (mp->format == FORMAT_PERCENT) {if (mp->type ==COUNTER_USEC ) - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), - t->counter[i] / interval_float /10000 ); + outp +=print_float_value (&printed, delim, t->counter[i] / interval_float /10000 );else - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * t->counter[i] / tsc); + outp +=print_float_value (&printed, delim,100.0 * t->counter[i] / tsc); } }
@@ -3255,16 +3257,13 @@ int format_counters(PER_THREAD_PARAMS)for (i =0 , pp = sys.perf_tp; pp; ++i, pp = pp->next) {if (pp->format ==FORMAT_RAW ) outp +=print_hex_value (pp->width, &printed, delim, t->perf_counter[i]); -else if (pp->format ==FORMAT_DELTA ) +else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (pp->width, &printed, delim, t->perf_counter[i]);else if (pp->format ==FORMAT_PERCENT ) {if (pp->type ==COUNTER_USEC ) - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), - t->perf_counter[i] / interval_float /10000 ); + outp +=print_float_value (&printed, delim, t->perf_counter[i] / interval_float /10000 );else - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * t->perf_counter[i] / tsc); + outp +=print_float_value (&printed, delim,100.0 * t->perf_counter[i] / tsc); } }
@@ -3320,20 +3319,18 @@ int format_counters(PER_THREAD_PARAMS) outp +=print_hex_value (mp->width, &printed, delim, c->counter[i]); else if (mp->format == FORMAT_DELTA || mp->format == FORMAT_AVERAGE) outp += print_decimal_value(mp->width, &printed, delim, c->counter[i]); - else if (mp->format == FORMAT_PERCENT) { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->counter[i] / tsc); - } + else if (mp->format == FORMAT_PERCENT) + outp += print_float_value(&printed, delim, 100.0 * c->counter[i] / tsc); }/* Added perf Core counters */ for (i =0 , pp = sys.perf_cp; pp; i++, pp = pp->next) {if (pp->format ==FORMAT_RAW ) outp +=print_hex_value (pp->width, &printed, delim, c->perf_counter[i]); -else if (pp->format ==FORMAT_DELTA ) +else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (pp->width, &printed, delim, c->perf_counter[i]); -else if (pp->format ==FORMAT_PERCENT ) { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->perf_counter[i] / tsc); - } +else if (pp->format ==FORMAT_PERCENT ) + outp +=print_float_value (&printed, delim,100.0 * c->perf_counter[i] / tsc); }/* Added PMT Core counters */
@@ -3347,12 +3344,12 @@ int format_counters(PER_THREAD_PARAMS)case PMT_TYPE_XTAL_TIME : value_converted =100.0 * value_raw / crystal_hz / interval_float; - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted); + outp +=print_float_value (&printed, delim, value_converted);break ;case PMT_TYPE_TCORE_CLOCK : value_converted =100.0 * value_raw / tcore_clock_freq_hz / interval_float; - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted); + outp +=print_float_value (&printed, delim, value_converted); } }
@@ -3500,26 +3497,25 @@ int format_counters(PER_THREAD_PARAMS)for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) {if (mp->format ==FORMAT_RAW ) outp +=print_hex_value (mp->width, &printed, delim, p->counter[i]); -else if (mp->format ==FORMAT_DELTA ) - outp +=print_decimal_value (mp->width, &printed, delim, p->counter[i]); -else if (mp->format ==FORMAT_PERCENT ) { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->counter[i] / tsc); - }else if (mp->type ==COUNTER_K2M ) +else if (mp->type ==COUNTER_K2M ) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), (unsigned int )p->counter[i] /1000 ); +else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) + outp +=print_decimal_value (mp->width, &printed, delim, p->counter[i]); +else if (mp->format ==FORMAT_PERCENT ) + outp +=print_float_value (&printed, delim,100.0 * p->counter[i] / tsc); }/* Added perf Package Counters */ for (i =0 , pp = sys.perf_pp; pp; i++, pp = pp->next) {if (pp->format ==FORMAT_RAW ) outp +=print_hex_value (pp->width, &printed, delim, p->perf_counter[i]); -else if (pp->format ==FORMAT_DELTA ) { - outp +=print_decimal_value (pp->width, &printed, delim, p->perf_counter[i]); - }else if (pp->format ==FORMAT_PERCENT ) { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->perf_counter[i] / tsc); - }else if (pp->type ==COUNTER_K2M ) { +else if (pp->type ==COUNTER_K2M ) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), (unsigned int )p->perf_counter[i] /1000 ); - } +else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) + outp +=print_decimal_value (pp->width, &printed, delim, p->perf_counter[i]); +else if (pp->format ==FORMAT_PERCENT ) + outp +=print_float_value (&printed, delim,100.0 * p->perf_counter[i] / tsc); }/* Added PMT Package Counters */
@@ -3533,12 +3529,12 @@ int format_counters(PER_THREAD_PARAMS)case PMT_TYPE_XTAL_TIME : value_converted =100.0 * value_raw / crystal_hz / interval_float; - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted); + outp +=print_float_value (&printed, delim, value_converted);break ;case PMT_TYPE_TCORE_CLOCK : value_converted =100.0 * value_raw / tcore_clock_freq_hz / interval_float; - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted); + outp +=print_float_value (&printed, delim, value_converted); } }
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 7/21 tools/power turbostat: Remove dead code
In reply to Len BrownFrom: Len Brown <[email protected]>
amperf_group_fd is never used.
--- tools/power/x86/turbostat/turbostat.c | 7 ------- 1 file changed, 7 deletions(-)
tools/power/x86/turbostat/turbostat.c +0 -7
@@ -466,8 +466,6 @@ static void bic_groups_init(void)#define PCL_10 14/* PC10 */ #define PCLUNL 15/* Unlimited */ -struct amperf_group_fd ; -char *proc_stat ="/proc/stat" ;FILE *outf;int *fd_percpu;
@@ -4418,11 +4416,6 @@ int get_core_throt_cnt(int cpu, unsigned long long *cnt)return 0 ; } -struct amperf_group_fd { -int aperf;/* Also the group descriptor */ -int mperf; -}; -static int read_perf_counter_info (const char *const path,const char *const parse_format,void *value_ptr) {int fdmt;
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 8/21 tools/power turbostat: Add LLC stats
In reply to Len BrownFrom: Len Brown <[email protected]>
LLCkRPS = Last Level Cache Thousands of References Per Second LLC%hit = Last Level Cache Hit %
These columns are enabled by-default.
They can be controlled with the --show/--hide options by individual column names above,
or together using the "llc" or "cache" groups.
--- tools/power/x86/turbostat/turbostat.8 | 6 +- tools/power/x86/turbostat/turbostat.c | 186 ++++++++++++++++++++++---- 2 files changed, 164 insertions(+), 28 deletions(-)
tools/power/x86/turbostat/turbostat.8 +5 -1
@@ -101,7 +101,7 @@ The column name "all" can be used to enable all disabled-by-default built-in cou .PP \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. .PP -\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 "pct_idle". "cpuidle" (default disabled) includes cpuidle software invocation counters. "swidle" includes "cpuidle" plus "pct_idle". "hwidle" includes only hardware based idle residency counters. Older versions of turbostat used the term "sysfs" for what is now "swidle". +\fB--show CATEGORY --hide CATEGORY\fP Show and hide also accept a comma-separated-list of CATEGORIES of columns: "all", "topology", "idle", "frequency", "power", "cpuidle", "hwidle", "swidle", "cache", "llc", "other". "idle" (enabled by default), includes "hwidle" and "pct_idle". "cpuidle" (default disabled) includes cpuidle software invocation counters. "swidle" includes "cpuidle" plus "pct_idle". "hwidle" includes only hardware based idle residency counters. Older versions of turbostat used the term "sysfs" for what is now "swidle". .PP \fB--Dump\fP displays the raw counter values. .PP
@@ -159,6 +159,10 @@ The system configuration dump (if --quiet is not used) is followed by statistics .PP \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. .PP +\fBLLCkRPS\fP Last Level Cache Thousands of References Per Second. For CPUs with an L3 LLC, this is the number of references that CPU made to the L3 (and the number of misses that CPU made to it's L2). For CPUs with an L2 LLC, this is the number of references to the L2 (and the number of misses to the CPU's L1). The system summary row shows the sum for all CPUs. In both cases, the value displayed is the actual value divided by 1000 in the interest of usually fitting into 8 columns. +.PP +\fBLLC%hit\fP Last Level Cache Hit Rate %. Hit Rate Percent = 100.0 * (References - Misses)/References. The system summary row shows the weighted average for all CPUs (100.0 * (Sum_References - Sum_Misses)/Sum_References). +.PP \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. .PP \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.
tools/power/x86/turbostat/turbostat.c +159 -27
459 lines not on this page · raw message
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 9/21 tools/power turbostat: Set per_cpu_msr_sum to NULL after free
In reply to Len BrownFrom: Emily Ehlert <[email protected]>
Set per_cpu_msr_sum to NULL after freeing it in the error path of msr_sum_record() to prevent potential use-after-free issues.
--- tools/power/x86/turbostat/turbostat.c | 1 + 1 file changed, 1 insertion(+)
tools/power/x86/turbostat/turbostat.c +1 -0
@@ -6652,6 +6652,7 @@ void msr_sum_record(void)timer_delete (timerid); release_msr:free (per_cpu_msr_sum); + per_cpu_msr_sum =NULL ; }/*
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 10/21 tools/power turbostat: Add run-time MSR driver probe
In reply to Len BrownFrom: Len Brown <[email protected]>
Rather than starting down the conditional-compile road...
Probe the location of the MSR files at run-time.
--- tools/power/x86/turbostat/turbostat.c | 68 +++++++++++++++------------ 1 file changed, 39 insertions(+), 29 deletions(-)
tools/power/x86/turbostat/turbostat.c +39 -29
@@ -142,6 +142,7 @@ struct msr_counter {#define FLAGS_SHOW (1 << 1)#define SYSFS_PERCPU (1 << 1) }; +static int use_android_msr_path;struct msr_counter bic[] = { {0x0 ,"usec" ,NULL ,0 ,0 ,0 ,NULL ,0 },
@@ -2413,20 +2414,11 @@ int get_msr_fd(int cpu)if (fd)return fd; -#if defined(ANDROID ) -sprintf (pathname,"/dev/msr%d" , cpu); -#else -sprintf (pathname,"/dev/cpu/%d/msr" , cpu); -#endif +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , cpu); fd =open (pathname,O_RDONLY );if (fd <0 ) -#if defined(ANDROID ) -err (-1 ,"%s open failed, try chown or chmod +r /dev/msr*, " -"or run with --no-msr, or run as root" , pathname); -#else -err (-1 ,"%s open failed, try chown or chmod +r /dev/cpu/*/msr, " -"or run with --no-msr, or run as root" , pathname); -#endif +err (-1 ,"%s open failed, try chown or chmod +r %s, " +"or run with --no-msr, or run as root" , pathname, use_android_msr_path ?"/dev/msr*" :"/dev/cpu/*/msr" ); fd_percpu[cpu] = fd;return fd;
@@ -6777,21 +6769,43 @@ void turbostat_loop() } } -void check_dev_msr () +int probe_dev_msr (void ) +{ +struct stat sb; +char pathname[32 ]; + +sprintf (pathname,"/dev/msr%d" , base_cpu); +return !stat (pathname, &sb); +} + +int probe_dev_cpu_msr (void ) {struct stat sb;char pathname[32 ]; -if (no_msr) -return ; -#if defined(ANDROID ) -sprintf (pathname,"/dev/msr%d" , base_cpu); -#else sprintf (pathname,"/dev/cpu/%d/msr" , base_cpu); -#endif -if (stat (pathname, &sb)) -if (system ("/sbin/modprobe msr > /dev/null 2>&1" )) - no_msr =1 ; +return !stat (pathname, &sb); +} + +int probe_msr_driver (void ) +{ +if (probe_dev_msr ()) { + use_android_msr_path =1 ; +return 1 ; + } +return probe_dev_cpu_msr (); +} + +void check_msr_driver (void ) +{ +if (probe_msr_driver ()) +return ; + +if (system ("/sbin/modprobe msr > /dev/null 2>&1" )) + no_msr =1 ; + +if (!probe_msr_driver ()) + no_msr =1 ; }/*
@@ -6846,11 +6860,7 @@ void check_msr_permission(void) failed +=check_for_cap_sys_rawio ();/* test file permissions */ -#if defined(ANDROID ) -sprintf (pathname,"/dev/msr%d" , base_cpu); -#else -sprintf (pathname,"/dev/cpu/%d/msr" , base_cpu); -#endif +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , base_cpu);if (euidaccess (pathname,R_OK )) { failed++; }
@@ -9476,7 +9486,7 @@ bool has_added_counters(void)void check_msr_access (void ) { -check_dev_msr (); +check_msr_driver ();check_msr_permission ();if (no_msr)
@@ -10147,7 +10157,7 @@ int get_and_dump_counters(void)void print_version () { -fprintf (outf,"turbostat version 2025.10.24 - Len Brown <[email protected]>\n" ); +fprintf (outf,"turbostat version 2025.11.29 - Len Brown <[email protected]>\n" ); }#define COMMAND_LINE_SIZE 2048
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 11/21 tools/power x86_energy_perf_policy: Add Android MSR device support
In reply to Len BrownFrom: Kaushlendra Kumar <[email protected]>
Add support for Android MSR device paths which use /dev/msrN format instead of the standard Linux /dev/cpu/N/msr format. The tool now probes both path formats at startup and uses the appropriate one.
This enables x86_energy_perf_policy to work on Android systems where MSR devices follow a different naming convention while maintaining full compatibility with standard Linux systems.
--- .../x86_energy_perf_policy.c | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +46 -8
@@ -95,6 +95,9 @@ unsigned int bdx_highest_ratio;#define PATH_TO_CPU "/sys/devices/system/cpu/"#define SYSFS_PATH_MAX 255 +/* keep Default as a linux path */ +static int use_android_msr_path; +/* * maintain compatibility with original implementation, but don't document it: */
@@ -678,16 +681,41 @@ void err_on_hypervisor(void) "not supported on this virtual machine"); } +static void probe_msr_path_format (void ) +{ +struct stat sb; +char test_path[32 ]; + +/* Test standard Linux path */ +sprintf (test_path,"/dev/cpu/%d/msr" , base_cpu); +if (stat (test_path, &sb) ==0 ) { + use_android_msr_path =0 ; +return ; + } + +/* Test Android-style path */ +sprintf (test_path,"/dev/msr%d" , base_cpu); +if (stat (test_path, &sb) ==0 ) { + use_android_msr_path =1 ; +return ; + } + +/* If neither exists, keep the default Linux format */ + use_android_msr_path =0 ; +} +int get_msr (int cpu,int offset,unsigned long long *msr) {int retval;char pathname[32 ];int fd; -sprintf (pathname,"/dev/cpu/%d/msr" , cpu); +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , cpu); fd =open (pathname,O_RDONLY );if (fd <0 ) -err (-1 ,"%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root" , pathname); +err (-1 ,"%s open failed, try chown or chmod +r %s, or run as root" , + pathname, use_android_msr_path ?"/dev/msr*" :"/dev/cpu/*/msr" ); + retval =pread (fd, msr,sizeof (*msr), offset);if (retval !=sizeof (*msr)) {
@@ -708,10 +736,11 @@ int put_msr(int cpu, int offset, unsigned long long new_msr)int retval;int fd; -sprintf (pathname,"/dev/cpu/%d/msr" , cpu); +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , cpu); fd =open (pathname,O_RDWR );if (fd <0 ) -err (-1 ,"%s open failed, try chown or chmod +r /dev/cpu/*/msr, or run as root" , pathname); +err (-1 ,"%s open failed, try chown or chmod +r %s, or run as root" , + pathname, use_android_msr_path ?"/dev/msr*" :"/dev/cpu/*/msr" ); retval =pwrite (fd, &new_msr,sizeof (new_msr), offset);if (retval !=sizeof (new_msr))
@@ -1427,10 +1456,15 @@ void probe_dev_msr(void)struct stat sb;char pathname[32 ]; -sprintf (pathname,"/dev/cpu/%d/msr" , base_cpu); -if (stat (pathname, &sb)) -if (system ("/sbin/modprobe msr > /dev/null 2>&1" )) -err (-5 ,"no /dev/cpu/0/msr, Try \"# modprobe msr\" " ); +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , base_cpu); +if (stat (pathname, &sb)) { +if (system ("/sbin/modprobe msr > /dev/null 2>&1" )) { +if (use_android_msr_path) +err (-5 ,"no /dev/msr0, Try \"# modprobe msr\" " ); +else +err (-5 ,"no /dev/cpu/0/msr, Try \"# modprobe msr\" " ); + } + } } static void get_cpuid_or_exit(unsigned int leaf,
@@ -1547,6 +1581,10 @@ void parse_cpuid(void)int main (int argc,char **argv) {set_base_cpu (); + +/* probe MSR path */ +probe_msr_path_format (); +probe_dev_msr ();init_data_structures ();
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 12/21 tools/power x86_energy_perf_policy: Simplify Android MSR probe
In reply to Len BrownFrom: Len Brown <[email protected]>
no functional change
--- .../x86_energy_perf_policy.c | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +11 -27
@@ -95,7 +95,6 @@ unsigned int bdx_highest_ratio;#define PATH_TO_CPU "/sys/devices/system/cpu/"#define SYSFS_PATH_MAX 255 -/* keep Default as a linux path */ static int use_android_msr_path;/*
@@ -681,29 +680,6 @@ void err_on_hypervisor(void) "not supported on this virtual machine"); } -static void probe_msr_path_format (void ) -{ -struct stat sb; -char test_path[32 ]; - -/* Test standard Linux path */ -sprintf (test_path,"/dev/cpu/%d/msr" , base_cpu); -if (stat (test_path, &sb) ==0 ) { - use_android_msr_path =0 ; -return ; - } - -/* Test Android-style path */ -sprintf (test_path,"/dev/msr%d" , base_cpu); -if (stat (test_path, &sb) ==0 ) { - use_android_msr_path =1 ; -return ; - } - -/* If neither exists, keep the default Linux format */ - use_android_msr_path =0 ; -} -int get_msr (int cpu,int offset,unsigned long long *msr) {int retval;
@@ -1450,12 +1426,23 @@ void set_base_cpu(void)err (-ENODEV ,"No valid cpus found" ); } +static void probe_android_msr_path (void ) +{ +struct stat sb; +char test_path[32 ]; + +sprintf (test_path,"/dev/msr%d" , base_cpu); +if (stat (test_path, &sb) ==0 ) + use_android_msr_path =1 ; +}void probe_dev_msr (void ) {struct stat sb;char pathname[32 ]; +probe_android_msr_path (); +sprintf (pathname, use_android_msr_path ?"/dev/msr%d" :"/dev/cpu/%d/msr" , base_cpu);if (stat (pathname, &sb)) {if (system ("/sbin/modprobe msr > /dev/null 2>&1" )) {
@@ -1582,9 +1569,6 @@ int main(int argc, char **argv) {set_base_cpu (); -/* probe MSR path */ -probe_msr_path_format (); -probe_dev_msr ();init_data_structures ();
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 13/21 tools/power x86_energy_perf_policy: Fix format string in error message
In reply to Len BrownFrom: Malaya Kumar Rout <[email protected]>
The error message in validate_cpu_selected_set() uses an incomplete format specifier "cpu%" instead of "cpu%d", resulting in the error message printing "Requested cpu% is not present" rather than showing the actual CPU number.
Fix the format string to properly display the CPU number.
--- tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +1 -1
@@ -372,7 +372,7 @@ void validate_cpu_selected_set(void)for (cpu =0 ; cpu <= max_cpu_num; ++cpu) {if (CPU_ISSET_S (cpu, cpu_setsize, cpu_selected_set))if (!CPU_ISSET_S (cpu, cpu_setsize, cpu_present_set)) -errx (1 ,"Requested cpu% is not present" , cpu); +errx (1 ,"Requested cpu%d is not present" , cpu); } }
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 14/21 tools/power x86_energy_perf_policy: Fix potential NULL pointer dereference
In reply to Len BrownFrom: Malaya Kumar Rout <[email protected]>
In err_on_hypervisor(), strstr() is called to search for "flags" in the buffer, but the return value is not checked before being used in pointer arithmetic (flags - buffer). If strstr() returns NULL because "flags" is not found in /proc/cpuinfo, this will cause undefined behavior and likely a crash.
Add a NULL check after the strstr() call and handle the error appropriately by cleaning up resources and reporting a meaningful error message.
--- .../x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +6 -1
@@ -520,7 +520,7 @@ void for_packages(unsigned long long pkg_set, int (func)(int))void print_version (void ) { -printf ("x86_energy_perf_policy 2025.9.19 Len Brown <[email protected]>\n" ); +printf ("x86_energy_perf_policy 2025.11.22 Len Brown <[email protected]>\n" ); }void cmdline (int argc,char **argv)
@@ -662,6 +662,11 @@ void err_on_hypervisor(void) } flags =strstr (buffer,"flags" ); +if (!flags) { +fclose (cpuinfo); +free (buffer); +err (1 ,"Failed to find 'flags' in /proc/cpuinfo" ); + }rewind (cpuinfo);fseek (cpuinfo, flags - buffer,SEEK_SET );if (!fgets (buffer,4096 , cpuinfo)) {
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 15/21 tools/power turbostat: Validate RAPL MSRs for AWS Nitro Hypervisor
In reply to Len BrownFrom: Len Brown <[email protected]>
Even though the platform->plat_rapl_msrs enumeration may be accurate, a VM, such as AWS Nitro Hypervisor, may deny access to the underlying MSRs.
Probe if PKG_ENERGY is readable and non-zero.
If no, ignore all RAPL MSRs.
--- tools/power/x86/turbostat/turbostat.c | 156 ++++++++++++++++---------- 1 file changed, 98 insertions(+), 58 deletions(-)
tools/power/x86/turbostat/turbostat.c +98 -58
@@ -492,6 +492,7 @@ unsigned int quiet;unsigned int shown;unsigned int sums_need_wide_columns;unsigned int rapl_joules; +unsigned int valid_rapl_msrs;unsigned int summary_only;unsigned int list_header_only;unsigned int dump_only;
@@ -588,7 +589,7 @@ struct platform_features {bool has_cst_prewake_bit;/* Cstate prewake bit in MSR_IA32_POWER_CTL */ int trl_msrs;/* MSR_TURBO_RATIO_LIMIT/LIMIT1/LIMIT2/SECONDARY, Atom TRL MSRs */ int plr_msrs;/* MSR_CORE/GFX/RING_PERF_LIMIT_REASONS */ -int rapl_msrs;/* RAPL PKG/DRAM/CORE/GFX MSRs, AMD RAPL MSRs */ +int plat_rapl_msrs;/* RAPL PKG/DRAM/CORE/GFX MSRs, AMD RAPL MSRs */ bool has_per_core_rapl;/* Indicates cores energy collection is per-core, not per-package. AMD specific for now */ bool has_rapl_divisor;/* Divisor for Energy unit raw value from MSR_RAPL_POWER_UNIT */ bool has_fixed_rapl_unit;/* Fixed Energy Unit used for DRAM RAPL Domain */
@@ -743,7 +744,7 @@ static const struct platform_features snb_features = { .cst_limit = CST_LIMIT_SNB, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features snx_features = {
@@ -755,7 +756,7 @@ static const struct platform_features snx_features = { .cst_limit = CST_LIMIT_SNB, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM_ALL, };static const struct platform_features ivb_features = {
@@ -768,7 +769,7 @@ static const struct platform_features ivb_features = { .cst_limit = CST_LIMIT_SNB, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features ivx_features = {
@@ -780,7 +781,7 @@ static const struct platform_features ivx_features = { .cst_limit = CST_LIMIT_SNB, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE | TRL_LIMIT1, - .rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM_ALL, };static const struct platform_features hsw_features = {
@@ -794,7 +795,7 @@ static const struct platform_features hsw_features = { .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, .plr_msrs = PLR_CORE | PLR_GFX | PLR_RING, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features hsx_features = {
@@ -808,7 +809,7 @@ static const struct platform_features hsx_features = { .has_irtl_msrs = 1, .trl_msrs = TRL_BASE | TRL_LIMIT1 | TRL_LIMIT2, .plr_msrs = PLR_CORE | PLR_RING, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, .has_fixed_rapl_unit = 1, };
@@ -823,7 +824,7 @@ static const struct platform_features hswl_features = { .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, .plr_msrs = PLR_CORE | PLR_GFX | PLR_RING, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features hswg_features = {
@@ -837,7 +838,7 @@ static const struct platform_features hswg_features = { .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, .plr_msrs = PLR_CORE | PLR_GFX | PLR_RING, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features bdw_features = {
@@ -850,7 +851,7 @@ static const struct platform_features bdw_features = { .cst_limit = CST_LIMIT_HSW, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features bdwg_features = {
@@ -863,7 +864,7 @@ static const struct platform_features bdwg_features = { .cst_limit = CST_LIMIT_HSW, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE_ALL | RAPL_GFX | RAPL_PKG_POWER_INFO, };static const struct platform_features bdx_features = {
@@ -877,7 +878,7 @@ static const struct platform_features bdx_features = { .has_irtl_msrs = 1, .has_cst_auto_convension = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, .has_fixed_rapl_unit = 1, };
@@ -894,7 +895,7 @@ static const struct platform_features skl_features = { .has_ext_cst_msrs = 1, .trl_msrs = TRL_BASE, .tcc_offset_bits = 6, - .rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX | RAPL_PSYS, .enable_tsc_tweak = 1, };
@@ -911,7 +912,7 @@ static const struct platform_features cnl_features = { .has_ext_cst_msrs = 1, .trl_msrs = TRL_BASE, .tcc_offset_bits = 6, - .rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX | RAPL_PSYS, .enable_tsc_tweak = 1, };
@@ -929,7 +930,7 @@ static const struct platform_features adl_features = { .has_ext_cst_msrs = cnl_features.has_ext_cst_msrs, .trl_msrs = cnl_features.trl_msrs, .tcc_offset_bits = cnl_features.tcc_offset_bits, - .rapl_msrs = cnl_features.rapl_msrs, + .plat_rapl_msrs = cnl_features.plat_rapl_msrs, .enable_tsc_tweak = cnl_features.enable_tsc_tweak, };
@@ -947,7 +948,7 @@ static const struct platform_features lnl_features = { .has_ext_cst_msrs = adl_features.has_ext_cst_msrs, .trl_msrs = adl_features.trl_msrs, .tcc_offset_bits = adl_features.tcc_offset_bits, - .rapl_msrs = adl_features.rapl_msrs, + .plat_rapl_msrs = adl_features.plat_rapl_msrs, .enable_tsc_tweak = adl_features.enable_tsc_tweak, };
@@ -962,7 +963,7 @@ static const struct platform_features skx_features = { .has_irtl_msrs = 1, .has_cst_auto_convension = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, .has_fixed_rapl_unit = 1, };
@@ -978,7 +979,7 @@ static const struct platform_features icx_features = { .has_irtl_msrs = 1, .has_cst_prewake_bit = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, .has_fixed_rapl_unit = 1, };
@@ -995,7 +996,7 @@ static const struct platform_features spr_features = { .has_cst_prewake_bit = 1, .has_fixed_rapl_psys_unit = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, };static const struct platform_features dmr_features = {
@@ -1010,7 +1011,7 @@ static const struct platform_features dmr_features = { .has_fixed_rapl_psys_unit = spr_features.has_fixed_rapl_psys_unit, .trl_msrs = spr_features.trl_msrs, .has_msr_module_c6_res_ms = 1, /* DMR has Dual-Core-Module and MC6 MSR */ - .rapl_msrs = 0, /* DMR does not have RAPL MSRs */ + .plat_rapl_msrs = 0, /* DMR does not have RAPL MSRs */ .plr_msrs = 0, /* DMR does not have PLR MSRs */ .has_irtl_msrs = 0, /* DMR does not have IRTL MSRs */ .has_config_tdp = 0, /* DMR does not have CTDP MSRs */
@@ -1029,7 +1030,7 @@ static const struct platform_features srf_features = { .has_irtl_msrs = 1, .has_cst_prewake_bit = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, };static const struct platform_features grr_features = {
@@ -1045,7 +1046,7 @@ static const struct platform_features grr_features = { .has_irtl_msrs = 1, .has_cst_prewake_bit = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_PSYS, };static const struct platform_features slv_features = {
@@ -1058,7 +1059,7 @@ static const struct platform_features slv_features = { .has_msr_c6_demotion_policy_config = 1, .has_msr_atom_pkg_c6_residency = 1, .trl_msrs = TRL_ATOM, - .rapl_msrs = RAPL_PKG | RAPL_CORE, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE, .has_rapl_divisor = 1, .rapl_quirk_tdp = 30, };
@@ -1071,7 +1072,7 @@ static const struct platform_features slvd_features = { .cst_limit = CST_LIMIT_SLV, .has_msr_atom_pkg_c6_residency = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_CORE, + .plat_rapl_msrs = RAPL_PKG | RAPL_CORE, .rapl_quirk_tdp = 30, };
@@ -1092,7 +1093,7 @@ static const struct platform_features gmt_features = { .cst_limit = CST_LIMIT_GMT, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_PKG_POWER_INFO, };static const struct platform_features gmtd_features = {
@@ -1105,7 +1106,7 @@ static const struct platform_features gmtd_features = { .has_irtl_msrs = 1, .has_msr_core_c1_res = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_CORE_ENERGY_STATUS, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL | RAPL_CORE_ENERGY_STATUS, };static const struct platform_features gmtp_features = {
@@ -1117,7 +1118,7 @@ static const struct platform_features gmtp_features = { .cst_limit = CST_LIMIT_GMT, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG | RAPL_PKG_POWER_INFO, + .plat_rapl_msrs = RAPL_PKG | RAPL_PKG_POWER_INFO, };static const struct platform_features tmt_features = {
@@ -1128,7 +1129,7 @@ static const struct platform_features tmt_features = { .cst_limit = CST_LIMIT_GMT, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE, - .rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_CORE_ALL | RAPL_DRAM | RAPL_DRAM_PERF_STATUS | RAPL_GFX, .enable_tsc_tweak = 1, };
@@ -1140,7 +1141,7 @@ static const struct platform_features tmtd_features = { .cst_limit = CST_LIMIT_GMT, .has_irtl_msrs = 1, .trl_msrs = TRL_BASE | TRL_CORECOUNT, - .rapl_msrs = RAPL_PKG_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL, };static const struct platform_features knl_features = {
@@ -1152,7 +1153,7 @@ static const struct platform_features knl_features = { .cst_limit = CST_LIMIT_KNL, .has_msr_knl_core_c6_residency = 1, .trl_msrs = TRL_KNL, - .rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, + .plat_rapl_msrs = RAPL_PKG_ALL | RAPL_DRAM_ALL, .has_fixed_rapl_unit = 1, .need_perf_multiplier = 1, };
@@ -1161,7 +1162,7 @@ static const struct platform_features default_features = { };static const struct platform_features amd_features_with_rapl = { - .rapl_msrs =RAPL_AMD_F17H , + .plat_rapl_msrs =RAPL_AMD_F17H , .has_per_core_rapl =1 , .rapl_quirk_tdp =280 ,/* This is the max stock TDP of HEDT/Server Fam17h+ chips */ };
@@ -2136,7 +2137,7 @@ off_t idx_to_offset(int idx)switch (idx) {case IDX_PKG_ENERGY : -if (platform->rapl_msrs &RAPL_AMD_F17H ) +if (valid_rapl_msrs &RAPL_AMD_F17H ) offset =MSR_PKG_ENERGY_STAT ;else offset =MSR_PKG_ENERGY_STATUS ;
@@ -2202,19 +2203,19 @@ int idx_valid(int idx) {switch (idx) {case IDX_PKG_ENERGY : -return platform->rapl_msrs & (RAPL_PKG |RAPL_AMD_F17H ); +return valid_rapl_msrs & (RAPL_PKG |RAPL_AMD_F17H );case IDX_DRAM_ENERGY : -return platform->rapl_msrs &RAPL_DRAM ; +return valid_rapl_msrs &RAPL_DRAM ;case IDX_PP0_ENERGY : -return platform->rapl_msrs &RAPL_CORE_ENERGY_STATUS ; +return valid_rapl_msrs &RAPL_CORE_ENERGY_STATUS ;case IDX_PP1_ENERGY : -return platform->rapl_msrs &RAPL_GFX ; +return valid_rapl_msrs &RAPL_GFX ;case IDX_PKG_PERF : -return platform->rapl_msrs &RAPL_PKG_PERF_STATUS ; +return valid_rapl_msrs &RAPL_PKG_PERF_STATUS ;case IDX_DRAM_PERF : -return platform->rapl_msrs &RAPL_DRAM_PERF_STATUS ; +return valid_rapl_msrs &RAPL_DRAM_PERF_STATUS ;case IDX_PSYS_ENERGY : -return platform->rapl_msrs &RAPL_PSYS ; +return valid_rapl_msrs &RAPL_PSYS ;default :return 0 ; }
@@ -2517,7 +2518,7 @@ int add_rapl_msr_counter(int cpu, const struct rapl_counter_arch_info *cai) {int ret; -if (!(platform->rapl_msrs & cai->feature_mask)) +if (!(valid_rapl_msrs & cai->feature_mask))return -1 ; ret =add_msr_counter (cpu, cai->msr);
@@ -2850,10 +2851,10 @@ void print_header(char *delim)if (DO_BIC (BIC_CORE_THROT_CNT )) outp +=sprintf (outp,"%sCoreThr" , (printed++ ? delim :"" )); -if (platform->rapl_msrs && !rapl_joules) { +if (valid_rapl_msrs && !rapl_joules) {if (DO_BIC (BIC_CorWatt) && platform->has_per_core_rapl) outp +=sprintf (outp,"%sCorWatt" , (printed++ ? delim :"" )); - }else if (platform->rapl_msrs && rapl_joules) { + }else if (valid_rapl_msrs && rapl_joules) {if (DO_BIC (BIC_Cor_J) && platform->has_per_core_rapl) outp +=sprintf (outp,"%sCor_J" , (printed++ ? delim :"" )); }
@@ -7572,7 +7573,7 @@ double get_tdp_intel(void) {unsigned long long msr; -if (platform->rapl_msrs &RAPL_PKG_POWER_INFO ) +if (valid_rapl_msrs &RAPL_PKG_POWER_INFO )if (!get_msr (base_cpu,MSR_PKG_POWER_INFO , &msr))return ((msr >>0 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units;return get_quirk_tdp ();
@@ -7603,12 +7604,12 @@ void rapl_probe_intel(void)CLR_BIC (BIC_GFX_J , &bic_enabled); } -if (!platform->rapl_msrs || no_msr) +if (!valid_rapl_msrs || no_msr)return ; -if (!(platform->rapl_msrs &RAPL_PKG_PERF_STATUS )) +if (!(valid_rapl_msrs &RAPL_PKG_PERF_STATUS ))CLR_BIC (BIC_PKG__ , &bic_enabled); -if (!(platform->rapl_msrs &RAPL_DRAM_PERF_STATUS )) +if (!(valid_rapl_msrs &RAPL_DRAM_PERF_STATUS ))CLR_BIC (BIC_RAM__ , &bic_enabled);/* units on package 0, verify later other packages match */
@@ -7657,7 +7658,7 @@ void rapl_probe_amd(void)CLR_BIC (BIC_Cor_J, &bic_enabled); } -if (!platform->rapl_msrs || no_msr) +if (!valid_rapl_msrs || no_msr)return ;if (get_msr (base_cpu,MSR_RAPL_PWR_UNIT , &msr))
@@ -7847,7 +7848,7 @@ int print_rapl(PER_THREAD_PARAMS)UNUSED (c);UNUSED (p); -if (!platform->rapl_msrs) +if (!valid_rapl_msrs)return 0 ;/* RAPL counters are per package, so print only for 1st thread/package */
@@ -7860,7 +7861,7 @@ int print_rapl(PER_THREAD_PARAMS)return -1 ; } -if (platform->rapl_msrs &RAPL_AMD_F17H ) { +if (valid_rapl_msrs &RAPL_AMD_F17H ) { msr_name ="MSR_RAPL_PWR_UNIT" ;if (get_msr (cpu,MSR_RAPL_PWR_UNIT , &msr))return -1 ;
@@ -7873,7 +7874,7 @@ int print_rapl(PER_THREAD_PARAMS)fprintf (outf,"cpu%d: %s: 0x%08llx (%f Watts, %f Joules, %f sec.)\n" , cpu, msr_name, msr, rapl_power_units, rapl_energy_units, rapl_time_units); -if (platform->rapl_msrs &RAPL_PKG_POWER_INFO ) { +if (valid_rapl_msrs &RAPL_PKG_POWER_INFO ) {if (get_msr (cpu,MSR_PKG_POWER_INFO , &msr))return -5 ;
@@ -7886,7 +7887,7 @@ int print_rapl(PER_THREAD_PARAMS) ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); } -if (platform->rapl_msrs &RAPL_PKG ) { +if (valid_rapl_msrs &RAPL_PKG ) {if (get_msr (cpu,MSR_PKG_POWER_LIMIT , &msr))return -9 ;
@@ -7910,7 +7911,7 @@ int print_rapl(PER_THREAD_PARAMS) cpu, ((msr >> 0) & 0x1FFF) * rapl_power_units, (msr >> 31) & 1 ? "" : "UN"); } -if (platform->rapl_msrs &RAPL_DRAM_POWER_INFO ) { +if (valid_rapl_msrs &RAPL_DRAM_POWER_INFO ) {if (get_msr (cpu,MSR_DRAM_POWER_INFO , &msr))return -6 ;
@@ -7921,7 +7922,7 @@ int print_rapl(PER_THREAD_PARAMS) ((msr >>32 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); } -if (platform->rapl_msrs &RAPL_DRAM ) { +if (valid_rapl_msrs &RAPL_DRAM ) {if (get_msr (cpu,MSR_DRAM_POWER_LIMIT , &msr))return -9 ; fprintf(outf, "cpu%d: MSR_DRAM_POWER_LIMIT: 0x%08llx (%slocked)\n",
@@ -7929,20 +7930,20 @@ int print_rapl(PER_THREAD_PARAMS)print_power_limit_msr (cpu, msr,"DRAM Limit" ); } -if (platform->rapl_msrs &RAPL_CORE_POLICY ) { +if (valid_rapl_msrs &RAPL_CORE_POLICY ) {if (get_msr (cpu,MSR_PP0_POLICY , &msr))return -7 ;fprintf (outf,"cpu%d: MSR_PP0_POLICY: %lld\n" , cpu, msr &0xF ); } -if (platform->rapl_msrs &RAPL_CORE_POWER_LIMIT ) { +if (valid_rapl_msrs &RAPL_CORE_POWER_LIMIT ) {if (get_msr (cpu,MSR_PP0_POWER_LIMIT , &msr))return -9 ;fprintf (outf,"cpu%d: MSR_PP0_POWER_LIMIT: 0x%08llx (%slocked)\n" , cpu, msr, (msr >>31 ) &1 ?"" :"UN" );print_power_limit_msr (cpu, msr,"Cores Limit" ); } -if (platform->rapl_msrs &RAPL_GFX ) { +if (valid_rapl_msrs &RAPL_GFX ) {if (get_msr (cpu,MSR_PP1_POLICY , &msr))return -8 ;
@@ -7957,6 +7958,43 @@ int print_rapl(PER_THREAD_PARAMS)return 0 ; } +/* +* probe_rapl_msrs +* +* initialize global valid_rapl_msrs to platform->plat_rapl_msrs +* only if PKG_ENERGY counter is enumerated and reads non-zero +*/ +void probe_rapl_msrs (void ) +{ +int ret; +off_t offset; +unsigned long long msr_value; + +if (no_msr) +return ; + +if ((platform->plat_rapl_msrs & (RAPL_PKG |RAPL_AMD_F17H )) ==0 ) +return ; + + offset =idx_to_offset (IDX_PKG_ENERGY ); +if (offset <0 ) +return ; + + ret =get_msr (base_cpu, offset, &msr_value); +if (ret) { +if (debug) +fprintf (outf,"Can not read RAPL_PKG_ENERGY MSR(0x%llx)\n" , (unsigned long long )offset); +return ; + } +if (msr_value ==0 ) { +if (debug) +fprintf (outf,"RAPL_PKG_ENERGY MSR(0x%llx) == ZERO: disabling all RAPL MSRs\n" , (unsigned long long )offset); +return ; + } + + valid_rapl_msrs = platform->plat_rapl_msrs;/* success */ +} +/* * probe_rapl() *
@@ -7964,6 +8002,8 @@ int print_rapl(PER_THREAD_PARAMS)*/ void probe_rapl (void ) { +probe_rapl_msrs (); +if (genuine_intel)rapl_probe_intel ();if (authentic_amd || hygon_genuine)
@@ -7974,7 +8014,7 @@ void probe_rapl(void)print_rapl_sysfs (); -if (!platform->rapl_msrs || no_msr) +if (!valid_rapl_msrs || no_msr)return ;for_all_cpus (print_rapl,ODD_COUNTERS );
@@ -10157,7 +10197,7 @@ int get_and_dump_counters(void)void print_version () { -fprintf (outf,"turbostat version 2025.11.29 - Len Brown <[email protected]>\n" ); +fprintf (outf,"turbostat version 2025.12.01 - Len Brown <[email protected]>\n" ); }#define COMMAND_LINE_SIZE 2048
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 16/21 tools/power turbostat: Enhance perf probe
In reply to Len BrownFrom: Len Brown <[email protected]>
check_perf_access() will now check both IPC and LLC perf counters if they are enabled. If any fail, it now disables perf and all perf counters.
--- tools/power/x86/turbostat/turbostat.c | 54 ++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 10 deletions(-)
tools/power/x86/turbostat/turbostat.c +44 -10
@@ -2438,6 +2438,13 @@ static void bic_disable_msr_access(void)free_sys_msr_counters (); } +static void bic_disable_perf_access (void ) +{ +CLR_BIC (BIC_IPC , &bic_enabled); +CLR_BIC (BIC_LLC_RPS , &bic_enabled); +CLR_BIC (BIC_LLC_HIT , &bic_enabled); +} +static long perf_event_open (struct perf_event_attr *hw_event,pid_t pid,int cpu,int group_fd,unsigned long flags) {assert (!no_perf);
@@ -8327,26 +8334,23 @@ void print_dev_latency(void)close (fd); } -static int has_instr_count_access (void ) +static int has_perf_instr_count_access (void ) {int fd; -int has_access;if (no_perf)return 0 ; fd =open_perf_counter (base_cpu,PERF_TYPE_HARDWARE ,PERF_COUNT_HW_INSTRUCTIONS ,-1 ,0 ); - has_access = fd !=-1 ; -if (fd !=-1 )close (fd); -if (!has_access) +if (fd ==-1 )warnx ("Failed to access %s. Some of the counters may not be available\n" -"\tRun as root to enable them or use %s to disable the access explicitly" , -"instructions retired perf counter" ,"--no-perf" ); +"\tRun as root to enable them or use %s to disable the access explicitly" ,"perf instructions retired counter" , +"'--hide IPC' or '--no-perf'" ); -return has_access; +return (fd !=-1 ); } int add_rapl_perf_counter(int cpu, struct rapl_counter_info_t *rci, const struct rapl_counter_arch_info *cai,
@@ -9080,6 +9084,28 @@ void probe_pm_features(void)decode_misc_feature_control (); } +/* perf_llc_probe +* +* return 1 on success, else 0 +*/ +int has_perf_llc_access (void ) +{ +int fd; + +if (no_perf) +return 0 ; + + fd =open_perf_counter (base_cpu,PERF_TYPE_HARDWARE ,PERF_COUNT_HW_CACHE_REFERENCES ,-1 ,PERF_FORMAT_GROUP ); +if (fd !=-1 ) +close (fd); + +if (fd ==-1 ) +warnx ("Failed to access %s. Some of the counters may not be available\n" +"\tRun as root to enable them or use %s to disable the access explicitly" ,"perf LLC counters" ,"'--hide LLC' or '--no-perf'" ); + +return (fd !=-1 ); +} +void perf_llc_init (void ) {int cpu;
@@ -9535,8 +9561,16 @@ void check_msr_access(void)void check_perf_access (void ) { -if (no_perf || !BIC_IS_ENABLED (BIC_IPC ) || !has_instr_count_access ()) -CLR_BIC (BIC_IPC , &bic_enabled); +if (BIC_IS_ENABLED (BIC_IPC )) +if (!has_perf_instr_count_access ()) + no_perf =1 ; + +if (BIC_IS_ENABLED (BIC_LLC_RPS ) ||BIC_IS_ENABLED (BIC_LLC_HIT )) +if (!has_perf_llc_access ()) + no_perf =1 ; + +if (no_perf) +bic_disable_perf_access (); }bool perf_has_hybrid_devices (void )
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 17/21 tools/power turbostat: Validate APERF access for VMWARE
In reply to Len BrownFrom: Len Brown <[email protected]>
VMWARE correctly enumerates lack of APERF and MPERF in CPUID, but turbostat didn't consult that before attempting to access them.
Since VMWARE allows access, but always returns 0, turbostat got confusd into an infinite reset loop.
Head this off by listening to CPUID.6.APERF_MPERF (and rename the existing variable to make this more clear)
--- tools/power/x86/turbostat/turbostat.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/power/x86/turbostat/turbostat.c +7 -7
@@ -497,7 +497,7 @@ unsigned int summary_only;unsigned int list_header_only;unsigned int dump_only;unsigned int force_load; -unsigned int has_aperf; +unsigned int cpuid_has_aperf_mperf;unsigned int has_aperf_access;unsigned int has_epb;unsigned int has_turbo;
@@ -8404,7 +8404,7 @@ void linux_perf_init(void)if (access ("/proc/sys/kernel/perf_event_paranoid" ,F_OK ))return ; -if (BIC_IS_ENABLED (BIC_IPC ) && has_aperf) { +if (BIC_IS_ENABLED (BIC_IPC ) && cpuid_has_aperf_mperf) { fd_instr_count_percpu =calloc (topo.max_cpu_num +1 ,sizeof (int ));if (fd_instr_count_percpu ==NULL )err (-1 ,"calloc fd_instr_count_percpu" );
@@ -8524,7 +8524,7 @@ void rapl_perf_init(void)/* Assumes msr_counter_info is populated */ static int has_amperf_access (void ) { -return msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX ].present && +return cpuid_has_aperf_mperf && msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX ].present && msr_counter_arch_infos[MSR_ARCH_INFO_MPERF_INDEX ].present; }
@@ -8936,7 +8936,7 @@ void process_cpuid()*/ __cpuid (0x6 , eax, ebx, ecx, edx); - has_aperf = ecx & (1 <<0 ); + cpuid_has_aperf_mperf = ecx & (1 <<0 ); do_dts = eax & (1 <<0 );if (do_dts)BIC_PRESENT (BIC_CoreTmp);
@@ -8954,7 +8954,7 @@ void process_cpuid()if (!quiet) fprintf(outf, "CPUID(6): %sAPERF, %sTURBO, %sDTS, %sPTM, %sHWP, " "%sHWPnotify, %sHWPwindow, %sHWPepp, %sHWPpkg, %sEPB\n", - has_aperf ? "" : "No-", + cpuid_has_aperf_mperf ? "" : "No-", has_turbo ? "" : "No-", do_dts ? "" : "No-", do_ptm ? "" : "No-",
@@ -9032,7 +9032,7 @@ void process_cpuid() base_mhz, max_mhz, bus_mhz); } -if (has_aperf) +if (cpuid_has_aperf_mperf) aperf_mperf_multiplier = platform->need_perf_multiplier ?1024 :1 ;BIC_PRESENT (BIC_IRQ );
@@ -10231,7 +10231,7 @@ int get_and_dump_counters(void)void print_version () { -fprintf (outf,"turbostat version 2025.12.01 - Len Brown <[email protected]>\n" ); +fprintf (outf,"turbostat version 2025.12.02 - Len Brown <[email protected]>\n" ); }#define COMMAND_LINE_SIZE 2048
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 18/21 tools/power turbostat: Print "nan" for out of range percentages
In reply to Len BrownFrom: Len Brown <[email protected]>
Sometimes counters return junk.
For the cases where values > 100% is invalid, print "nan".
--- tools/power/x86/turbostat/turbostat.c | 92 +++++++++++++++------------ 1 file changed, 53 insertions(+), 39 deletions(-)
tools/power/x86/turbostat/turbostat.c +53 -39
@@ -2999,6 +2999,25 @@ void print_header(char *delim) outp +=sprintf (outp,"\n" ); } +/* +* pct() +* +* If absolute value is < 1.1, return percentage +* otherwise, return nan +* +* return value is appropriate for printing percentages with %f +* while flagging some obvious erroneous values. +*/ +double pct (double d) +{ + +double abs =fabs (d); + +if (abs <1.10 ) +return (100.0 * d); +return nan ("" ); +} +int dump_counters (PER_THREAD_PARAMS ) {int i;
@@ -3026,7 +3045,7 @@ int dump_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"LLC refs: %lld" , t->llc.references); outp +=sprintf (outp,"LLC miss: %lld" , t->llc.misses); - outp +=sprintf (outp,"LLC Hit%%: %.2f" ,100.0 * (t->llc.references - t->llc.misses) / t->llc.references); + outp +=sprintf (outp,"LLC Hit%%: %.2f" ,pct ((t->llc.references - t->llc.misses) / t->llc.references));for (i =0 , mp = sys.tp; mp; i++, mp = mp->next) { outp +=
@@ -3248,7 +3267,7 @@ int format_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ),1.0 / units * t->aperf / interval_float);if (DO_BIC (BIC_Busy)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * t->mperf / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (t->mperf / tsc));if (DO_BIC (BIC_Bzy_MHz)) {if (has_base_hz)
@@ -3291,7 +3310,7 @@ int format_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ), t->llc.references / interval_float /1000 );if (DO_BIC (BIC_LLC_HIT )) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),100.0 * (t->llc.references - t->llc.misses) / t->llc.references); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),pct ((t->llc.references - t->llc.misses) / t->llc.references)); }
@@ -3305,7 +3324,7 @@ int format_counters(PER_THREAD_PARAMS)if (mp->type ==COUNTER_USEC ) outp +=print_float_value (&printed, delim, t->counter[i] / interval_float /10000 );else - outp +=print_float_value (&printed, delim,100.0 * t->counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (t->counter[i] / tsc)); } }
@@ -3319,7 +3338,7 @@ int format_counters(PER_THREAD_PARAMS)if (pp->type ==COUNTER_USEC ) outp +=print_float_value (&printed, delim, t->perf_counter[i] / interval_float /10000 );else - outp +=print_float_value (&printed, delim,100.0 * t->perf_counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (t->perf_counter[i] / tsc)); } }
@@ -3333,34 +3352,34 @@ int format_counters(PER_THREAD_PARAMS)break ;case PMT_TYPE_XTAL_TIME : - value_converted =100.0 * value_raw / crystal_hz / interval_float; + value_converted =pct (value_raw / crystal_hz / interval_float); outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted);break ;case PMT_TYPE_TCORE_CLOCK : - value_converted =100.0 * value_raw / tcore_clock_freq_hz / interval_float; + value_converted =pct (value_raw / tcore_clock_freq_hz / interval_float); outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), value_converted); } }/* C1 */ if (DO_BIC (BIC_CPU_c1)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * t->c1 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (t->c1 / tsc));/* print per-core data only for 1st thread in core */ if (!is_cpu_first_thread_in_core (t, c)) goto done;if (DO_BIC (BIC_CPU_c3)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->c3 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (c->c3 / tsc));if (DO_BIC (BIC_CPU_c6)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->c6 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (c->c6 / tsc));if (DO_BIC (BIC_CPU_c7)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->c7 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (c->c7 / tsc));/* Mod%c6 */ if (DO_BIC (BIC_Mod_c6)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * c->mc6_us / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (c->mc6_us / tsc));if (DO_BIC (BIC_CoreTmp)) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), c->core_temp_c);
@@ -3376,7 +3395,7 @@ int format_counters(PER_THREAD_PARAMS)else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (mp->width, &printed, delim, c->counter[i]);else if (mp->format ==FORMAT_PERCENT ) - outp +=print_float_value (&printed, delim,100.0 * c->counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (c->counter[i] / tsc)); }/* Added perf Core counters */
@@ -3386,7 +3405,7 @@ int format_counters(PER_THREAD_PARAMS)else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (pp->width, &printed, delim, c->perf_counter[i]);else if (pp->format ==FORMAT_PERCENT ) - outp +=print_float_value (&printed, delim,100.0 * c->perf_counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (c->perf_counter[i] / tsc)); }/* Added PMT Core counters */
@@ -3399,12 +3418,12 @@ int format_counters(PER_THREAD_PARAMS)break ;case PMT_TYPE_XTAL_TIME : - value_converted =100.0 * value_raw / crystal_hz / interval_float; + value_converted =pct (value_raw / crystal_hz / interval_float); outp +=print_float_value (&printed, delim, value_converted);break ;case PMT_TYPE_TCORE_CLOCK : - value_converted =100.0 * value_raw / tcore_clock_freq_hz / interval_float; + value_converted =pct (value_raw / tcore_clock_freq_hz / interval_float); outp +=print_float_value (&printed, delim, value_converted); } }
@@ -3463,46 +3482,41 @@ int format_counters(PER_THREAD_PARAMS)/* Totl%C0, Any%C0 GFX%C0 CPUGFX% */ if (DO_BIC (BIC_Totl_c0)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pkg_wtd_core_c0 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100 * p->pkg_wtd_core_c0 / tsc);/* can exceed 100% */ if (DO_BIC (BIC_Any_c0)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pkg_any_core_c0 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pkg_any_core_c0 / tsc));if (DO_BIC (BIC_GFX_c0)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pkg_any_gfxe_c0 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pkg_any_gfxe_c0 / tsc));if (DO_BIC (BIC_CPUGFX )) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pkg_both_core_gfxe_c0 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pkg_both_core_gfxe_c0 / tsc));if (DO_BIC (BIC_Pkgpc2)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc2 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc2 / tsc));if (DO_BIC (BIC_Pkgpc3)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc3 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc3 / tsc));if (DO_BIC (BIC_Pkgpc6)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc6 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc6 / tsc));if (DO_BIC (BIC_Pkgpc7)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc7 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc7 / tsc));if (DO_BIC (BIC_Pkgpc8)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc8 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc8 / tsc));if (DO_BIC (BIC_Pkgpc9)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc9 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc9 / tsc));if (DO_BIC (BIC_Pkgpc10)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->pc10 / tsc); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pc10 / tsc));if (DO_BIC (BIC_Diec6)) - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100.0 * p->die_c6 / crystal_hz / interval_float); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->die_c6 / crystal_hz / interval_float));if (DO_BIC (BIC_CPU_LPI )) {if (p->cpu_lpi >=0 ) - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), -100.0 * p->cpu_lpi /1000000.0 / interval_float); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->cpu_lpi /1000000.0 / interval_float));else outp +=sprintf (outp,"%s(neg)" , (printed++ ? delim :"" )); }if (DO_BIC (BIC_SYS_LPI )) {if (p->sys_lpi >=0 ) - outp += -sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), -100.0 * p->sys_lpi /1000000.0 / interval_float); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->sys_lpi /1000000.0 / interval_float));else outp +=sprintf (outp,"%s(neg)" , (printed++ ? delim :"" )); }
@@ -3556,7 +3570,7 @@ int format_counters(PER_THREAD_PARAMS)else if (mp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (mp->width, &printed, delim, p->counter[i]);else if (mp->format ==FORMAT_PERCENT ) - outp +=print_float_value (&printed, delim,100.0 * p->counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (p->counter[i] / tsc)); }/* Added perf Package Counters */
@@ -3569,7 +3583,7 @@ int format_counters(PER_THREAD_PARAMS)else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (pp->width, &printed, delim, p->perf_counter[i]);else if (pp->format ==FORMAT_PERCENT ) - outp +=print_float_value (&printed, delim,100.0 * p->perf_counter[i] / tsc); + outp +=print_float_value (&printed, delim,pct (p->perf_counter[i] / tsc)); }/* Added PMT Package Counters */
@@ -3582,12 +3596,12 @@ int format_counters(PER_THREAD_PARAMS)break ;case PMT_TYPE_XTAL_TIME : - value_converted =100.0 * value_raw / crystal_hz / interval_float; + value_converted =pct (value_raw / crystal_hz / interval_float); outp +=print_float_value (&printed, delim, value_converted);break ;case PMT_TYPE_TCORE_CLOCK : - value_converted =100.0 * value_raw / tcore_clock_freq_hz / interval_float; + value_converted =pct (value_raw / tcore_clock_freq_hz / interval_float); outp +=print_float_value (&printed, delim, value_converted); } }
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 19/21 tools/power turbostat: Print percentages in 8-columns
In reply to Len BrownFrom: Len Brown <[email protected]>
Added counters that are FORMAT_PERCENT do not need to be 64-bits -- 32 is plenty. This allows the output code to fit them, and their header, into 8-columns.
--- tools/power/x86/turbostat/turbostat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/power/x86/turbostat/turbostat.c +2 -2
@@ -3482,7 +3482,7 @@ int format_counters(PER_THREAD_PARAMS)/* Totl%C0, Any%C0 GFX%C0 CPUGFX% */ if (DO_BIC (BIC_Totl_c0)) - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100 * p->pkg_wtd_core_c0 / tsc);/* can exceed 100% */ + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),100 * p->pkg_wtd_core_c0 / tsc);/* can exceed 100% */ if (DO_BIC (BIC_Any_c0)) outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ),pct (p->pkg_any_core_c0 / tsc));if (DO_BIC (BIC_GFX_c0))
@@ -10997,7 +10997,7 @@ void probe_cpuidle_residency(void)if (is_deferred_skip (name_buf))continue ; -add_counter (0 , path, name_buf,64 ,SCOPE_CPU ,COUNTER_USEC ,FORMAT_PERCENT ,SYSFS_PERCPU ,0 ); +add_counter (0 , path, name_buf,32 ,SCOPE_CPU ,COUNTER_USEC ,FORMAT_PERCENT ,SYSFS_PERCPU ,0 );if (state > max_state) max_state = state;
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 20/21 tools/power turbostat: Print wide names only for RAW 64-bit columns
In reply to Len BrownFrom: Len Brown <[email protected]>
Print a wide column header only for the case of a 64-bit RAW counter.
It turns out that wide column headers otherwise are more harm than good.
--- tools/power/x86/turbostat/turbostat.c | 40 ++++++++++++++------------- 1 file changed, 21 insertions(+), 19 deletions(-)
tools/power/x86/turbostat/turbostat.c +21 -19
@@ -2723,20 +2723,22 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)/* * print_name() -* Print column header name for 64-bit counter in 16 columns (at least 8-char plus a tab) +* Print column header name for raw 64-bit counter in 16 columns (at least 8-char plus a tab) * Otherwise, allow the name + tab to fit within 8-coumn tab-stop. * In both cases, left justififed, just like other turbostat columns, * to allow the column values to consume the tab. * -* Yes, 32-bit counters can overflow 8-columns, but then they are usually 64-bit counters. -* 64-bit counters can overflow 16-columns, but rarely do. +* Yes, 32-bit counters can overflow 8-columns, and +* 64-bit counters can overflow 16-columns, but that is uncommon. */ -static inline int print_name (int width,int *printed,char *delim,char *name) +static inline int print_name (int width,int *printed,char *delim,char *name,enum counter_type type,enum counter_format format) { -if (width <=32 ) -return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); -else +UNUSED (type); + +if (format ==FORMAT_RAW && width >=64 )return (sprintf (outp,"%s%-8s" , (*printed++ ? delim :"" ), name)); +else +return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); }static inline int print_hex_value (int width,int *printed,char *delim,unsigned long long value) {
@@ -2819,21 +2821,21 @@ void print_header(char *delim) outp +=sprintf (outp,"%sLLC%%hit" , (printed++ ? delim :"" ));for (mp = sys.tp; mp; mp = mp->next) - outp +=print_name (mp->width, &printed, delim, mp->name); + outp +=print_name (mp->width, &printed, delim, mp->name, mp->type, mp->format);for (pp = sys.perf_tp; pp; pp = pp->next) - outp +=print_name (pp->width, &printed, delim, pp->name); + outp +=print_name (pp->width, &printed, delim, pp->name, pp->type, pp->format); ppmt = sys.pmt_tp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : - outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name); + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=print_name (32 , &printed, delim, ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ; }
@@ -2867,22 +2869,22 @@ void print_header(char *delim) }for (mp = sys.cp; mp; mp = mp->next) - outp +=print_name (mp->width, &printed, delim, mp->name); + outp +=print_name (mp->width, &printed, delim, mp->name, mp->type, mp->format);for (pp = sys.perf_cp; pp; pp = pp->next) - outp +=print_name (pp->width, &printed, delim, pp->name); + outp +=print_name (pp->width, &printed, delim, pp->name, pp->type, pp->format); ppmt = sys.pmt_cp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : - outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name); + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=print_name (32 , &printed, delim, ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ; }
@@ -2970,21 +2972,21 @@ void print_header(char *delim) outp +=sprintf (outp,"%sUncMHz" , (printed++ ? delim :"" ));for (mp = sys.pp; mp; mp = mp->next) - outp +=print_name (mp->width, &printed, delim, mp->name); + outp +=print_name (mp->width, &printed, delim, mp->name, mp->type, mp->format);for (pp = sys.perf_pp; pp; pp = pp->next) - outp +=print_name (pp->width, &printed, delim, pp->name); + outp +=print_name (pp->width, &printed, delim, pp->name, pp->type, pp->format); ppmt = sys.pmt_pp;while (ppmt) {switch (ppmt->type) {case PMT_TYPE_RAW : - outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name); + outp +=print_name (pmt_counter_get_width (ppmt), &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ;case PMT_TYPE_XTAL_TIME :case PMT_TYPE_TCORE_CLOCK : - outp +=print_name (32 , &printed, delim, ppmt->name); + outp +=print_name (32 , &printed, delim, ppmt->name,COUNTER_ITEMS , ppmt->format);break ; }
Signature · 1 line
2.45.2
Len Brown
maintainerPATCH 21/21 tools/power turbostat: version 2025.12.02
In reply to Len BrownFrom: Len Brown <[email protected]>
Since release 2025.09.09:
Add LLC statistics columns:
LLCkRPS = Last Level Cache Thousands of References Per Second LLC%hit = Last Level Cache Hit %
Recognize Wildcat Lake and Nova Lake platforms
Add MSR check for Android
Add APERF check for VMWARE
Add RAPL check for AWS
minor fixes
This patch:
White-space only, resulting from running Lindent on everything except the tab-justified data-tables, and using -l150 instead of -l80 to allow long lines.
--- tools/power/x86/turbostat/turbostat.c | 326 +++++++++----------------- 1 file changed, 108 insertions(+), 218 deletions(-)
tools/power/x86/turbostat/turbostat.c +108 -218
@@ -563,8 +563,7 @@ static struct gfx_sysfs_info gfx_info[GFX_MAX];int get_msr (int cpu,off_t offset,unsigned long long *msr);int add_counter (unsigned int msr_num,char *path,char *name, -unsigned int width,enum counter_scope scope, -enum counter_type type,enum counter_format format,int flags,int package_num); +unsigned int width,enum counter_scope scope,enum counter_type type,enum counter_format format,int flags,int package_num);/* Model specific support Start */
@@ -1308,8 +1307,7 @@ char *progname;#define CPU_SUBSET_MAXCPUS 8192/* need to use before probe... */ cpu_set_t *cpu_present_set, *cpu_possible_set, *cpu_effective_set, *cpu_allowed_set, *cpu_affinity_set, *cpu_subset; -size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, - cpu_subset_size; +size_t cpu_present_setsize, cpu_possible_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affinity_setsize, cpu_subset_size;#define MAX_ADDED_THREAD_COUNTERS 24#define MAX_ADDED_CORE_COUNTERS 8#define MAX_ADDED_PACKAGE_COUNTERS 16
@@ -2696,8 +2694,7 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)if (mode ==SHOW_LIST ) { deferred_add_names[deferred_add_index++] = name_list;if (deferred_add_index >=MAX_DEFERRED ) { -fprintf (stderr,"More than max %d un-recognized --add options '%s'\n" , -MAX_DEFERRED , name_list); +fprintf (stderr,"More than max %d un-recognized --add options '%s'\n" ,MAX_DEFERRED , name_list);help ();exit (1 ); }
@@ -2706,8 +2703,7 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)if (debug)fprintf (stderr,"deferred \"%s\"\n" , name_list);if (deferred_skip_index >=MAX_DEFERRED ) { -fprintf (stderr,"More than max %d un-recognized --skip options '%s'\n" , -MAX_DEFERRED , name_list); +fprintf (stderr,"More than max %d un-recognized --skip options '%s'\n" ,MAX_DEFERRED , name_list);help ();exit (1 ); }
@@ -2740,6 +2736,7 @@ static inline int print_name(int width, int *printed, char *delim, char *name, eelse return (sprintf (outp,"%s%s" , (*printed++ ? delim :"" ), name)); } +static inline int print_hex_value (int width,int *printed,char *delim,unsigned long long value) {if (width <=32 )
@@ -2747,6 +2744,7 @@ static inline int print_hex_value(int width, int *printed, char *delim, unsignedelse return (sprintf (outp,"%s%016llx" , (*printed++ ? delim :"" ), value)); } +static inline int print_decimal_value (int width,int *printed,char *delim,unsigned long long value) {if (width <=32 )
@@ -2754,6 +2752,7 @@ static inline int print_decimal_value(int width, int *printed, char *delim, unsielse return (sprintf (outp,"%s%-8lld" , (*printed++ ? delim :"" ), value)); } +static inline int print_float_value (int *printed,char *delim,double value) {return (sprintf (outp,"%s%0.2f" , (*printed++ ? delim :"" ), value));
@@ -3050,9 +3049,7 @@ int dump_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"LLC Hit%%: %.2f" ,pct ((t->llc.references - t->llc.misses) / t->llc.references));for (i =0 , mp = sys.tp; mp; i++, mp = mp->next) { - outp += -sprintf (outp,"tADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, - t->counter[i], mp->sp->path); + outp +=sprintf (outp,"tADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, t->counter[i], mp->sp->path); } }
@@ -3071,9 +3068,7 @@ int dump_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"Joules: %0llX (scale: %lf)\n" , energy_value, energy_scale);for (i =0 , mp = sys.cp; mp; i++, mp = mp->next) { - outp += -sprintf (outp,"cADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, - c->counter[i], mp->sp->path); + outp +=sprintf (outp,"cADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, c->counter[i], mp->sp->path); } outp +=sprintf (outp,"mc6_us: %016llX\n" , c->mc6_us); }
@@ -3108,9 +3103,7 @@ int dump_counters(PER_THREAD_PARAMS) outp +=sprintf (outp,"PTM: %dC\n" , p->pkg_temp_c);for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) { - outp += -sprintf (outp,"pADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, - p->counter[i], mp->sp->path); + outp +=sprintf (outp,"pADDED [%d] %8s msr0x%x: %08llX %s\n" , i, mp->name, mp->msr_num, p->counter[i], mp->sp->path); } }
@@ -3246,8 +3239,7 @@ int format_counters(PER_THREAD_PARAMS) }if (DO_BIC (BIC_Node)) {if (t) - outp +=sprintf (outp,"%s%d" , - (printed++ ? delim :"" ), cpus[t->cpu_id].physical_node_id); + outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), cpus[t->cpu_id].physical_node_id);else outp +=sprintf (outp,"%s-" , (printed++ ? delim :"" )); }
@@ -3273,11 +3265,9 @@ int format_counters(PER_THREAD_PARAMS)if (DO_BIC (BIC_Bzy_MHz)) {if (has_base_hz) - outp += -sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ), base_hz / units * t->aperf / t->mperf); + outp +=sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ), base_hz / units * t->aperf / t->mperf);else - outp +=sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ), - tsc / units * t->aperf / t->mperf / interval_float); + outp +=sprintf (outp,"%s%.0f" , (printed++ ? delim :"" ), tsc / units * t->aperf / t->mperf / interval_float); }if (DO_BIC (BIC_TSC_MHz))
@@ -3315,7 +3305,6 @@ int format_counters(PER_THREAD_PARAMS) outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),pct ((t->llc.references - t->llc.misses) / t->llc.references)); } -/* Added Thread Counters */ for (i =0 , mp = sys.tp; mp; i++, mp = mp->next) {if (mp->format ==FORMAT_RAW )
@@ -3431,12 +3420,9 @@ int format_counters(PER_THREAD_PARAMS) }if (DO_BIC (BIC_CorWatt) && platform->has_per_core_rapl) - outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&c->core_energy,RAPL_UNIT_WATTS , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&c->core_energy,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_Cor_J) && platform->has_per_core_rapl) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&c->core_energy,RAPL_UNIT_JOULES , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&c->core_energy,RAPL_UNIT_JOULES , interval_float));/* print per-package data only for 1st core in package */ if (!is_cpu_first_core_in_package (t, p))
@@ -3451,8 +3437,7 @@ int format_counters(PER_THREAD_PARAMS)if (p->gfx_rc6_ms ==-1 ) {/* detect GFX counter reset */ outp +=sprintf (outp,"%s**.**" , (printed++ ? delim :"" )); }else { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), - p->gfx_rc6_ms /10.0 / interval_float); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), p->gfx_rc6_ms /10.0 / interval_float); } }
@@ -3469,8 +3454,7 @@ int format_counters(PER_THREAD_PARAMS)if (p->sam_mc6_ms ==-1 ) {/* detect GFX counter reset */ outp +=sprintf (outp,"%s**.**" , (printed++ ? delim :"" )); }else { - outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), - p->sam_mc6_ms /10.0 / interval_float); + outp +=sprintf (outp,"%s%.2f" , (printed++ ? delim :"" ), p->sam_mc6_ms /10.0 / interval_float); } }
@@ -3524,41 +3508,27 @@ int format_counters(PER_THREAD_PARAMS) }if (DO_BIC (BIC_PkgWatt)) - outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_pkg,RAPL_UNIT_WATTS , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_pkg,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_CorWatt) && !platform->has_per_core_rapl) - outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_cores,RAPL_UNIT_WATTS , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_cores,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_GFXWatt)) - outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_gfx,RAPL_UNIT_WATTS , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_gfx,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_RAMWatt)) - outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_dram,RAPL_UNIT_WATTS , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_dram,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_Pkg_J)) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_pkg,RAPL_UNIT_JOULES , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_pkg,RAPL_UNIT_JOULES , interval_float));if (DO_BIC (BIC_Cor_J) && !platform->has_per_core_rapl) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_cores,RAPL_UNIT_JOULES , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_cores,RAPL_UNIT_JOULES , interval_float));if (DO_BIC (BIC_GFX_J )) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_gfx,RAPL_UNIT_JOULES , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_gfx,RAPL_UNIT_JOULES , interval_float));if (DO_BIC (BIC_RAM_J )) - outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->energy_dram,RAPL_UNIT_JOULES , interval_float)); + outp +=sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->energy_dram,RAPL_UNIT_JOULES , interval_float));if (DO_BIC (BIC_PKG__ )) outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->rapl_pkg_perf_status,RAPL_UNIT_WATTS , interval_float)); +sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->rapl_pkg_perf_status,RAPL_UNIT_WATTS , interval_float));if (DO_BIC (BIC_RAM__ )) outp += -sprintf (outp, fmt8, (printed++ ? delim :"" ), -rapl_counter_get_value (&p->rapl_dram_perf_status,RAPL_UNIT_WATTS , interval_float)); +sprintf (outp, fmt8, (printed++ ? delim :"" ),rapl_counter_get_value (&p->rapl_dram_perf_status,RAPL_UNIT_WATTS , interval_float));/* UncMHz */ if (DO_BIC (BIC_UNCORE_MHZ )) outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), p->uncore_mhz);
@@ -3580,8 +3550,7 @@ int format_counters(PER_THREAD_PARAMS)if (pp->format ==FORMAT_RAW ) outp +=print_hex_value (pp->width, &printed, delim, p->perf_counter[i]);else if (pp->type ==COUNTER_K2M ) - outp += -sprintf (outp,"%s%d" , (printed++ ? delim :"" ), (unsigned int )p->perf_counter[i] /1000 ); + outp +=sprintf (outp,"%s%d" , (printed++ ? delim :"" ), (unsigned int )p->perf_counter[i] /1000 );else if (pp->format ==FORMAT_DELTA || mp->format ==FORMAT_AVERAGE ) outp +=print_decimal_value (pp->width, &printed, delim, p->perf_counter[i]);else if (pp->format ==FORMAT_PERCENT )
@@ -3719,8 +3688,7 @@ int delta_package(struct pkg_data *new, struct pkg_data *old) old->energy_gfx.raw_value = new->energy_gfx.raw_value - old->energy_gfx.raw_value; old->energy_dram.raw_value = new->energy_dram.raw_value - old->energy_dram.raw_value; old->rapl_pkg_perf_status.raw_value = new->rapl_pkg_perf_status.raw_value - old->rapl_pkg_perf_status.raw_value; - old->rapl_dram_perf_status.raw_value = - new->rapl_dram_perf_status.raw_value - old->rapl_dram_perf_status.raw_value; + old->rapl_dram_perf_status.raw_value = new->rapl_dram_perf_status.raw_value - old->rapl_dram_perf_status.raw_value;for (i =0 , mp = sys.pp; mp; i++, mp = mp->next) {if (mp->format ==FORMAT_RAW )
@@ -3827,8 +3795,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d/* check for TSC < 1 Mcycles over interval */ if (old->tsc < (1000 *1000 ))errx (-3 ,"Insanely slow TSC rate, TSC stops in idle?\n" -"You can disable all c-states by booting with \"idle=poll\"\n" -"or just the deep ones with \"processor.max_cstate=1\"" ); +"You can disable all c-states by booting with \"idle=poll\"\n" "or just the deep ones with \"processor.max_cstate=1\"" ); old->c1 = new->c1 - old->c1;
@@ -3857,8 +3824,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d old->c1 =0 ; else {/* normal case, derive c1 */ - old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 - - core_delta->c6 - core_delta->c7; + old->c1 = (old->tsc * tsc_tweak) - old->mperf - core_delta->c3 - core_delta->c6 - core_delta->c7; } }
@@ -3910,8 +3876,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_dreturn 0 ; } -int delta_cpu (struct thread_data *t,struct core_data *c, -struct pkg_data *p,struct thread_data *t2,struct core_data *c2,struct pkg_data *p2) +int delta_cpu (struct thread_data *t,struct core_data *c,struct pkg_data *p,struct thread_data *t2,struct core_data *c2,struct pkg_data *p2) {int retval =0 ;
@@ -4391,8 +4356,7 @@ unsigned long long get_legacy_uncore_mhz(int package)*/ for (die =0 ; die <= topo.max_die_id; ++die) { -sprintf (path,"/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/current_freq_khz" , - package, die); +sprintf (path,"/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d/current_freq_khz" , package, die);if (access (path,R_OK ) ==0 )return (snapshot_sysfs_counter (path) /1000 );
@@ -4702,8 +4666,7 @@ int get_rapl_counters(int cpu, unsigned int domain, struct core_data *c, structconst ssize_t actual_read_size =read (rci->fd_perf, &perf_data[0 ],sizeof (perf_data));if (actual_read_size != expected_read_size) -err (-1 ,"%s: failed to read perf_data (%zu %zu)" , __func__, expected_read_size, - actual_read_size); +err (-1 ,"%s: failed to read perf_data (%zu %zu)" , __func__, expected_read_size, actual_read_size); }for (unsigned int i =0 , pi =1 ; i <NUM_RAPL_COUNTERS ; ++i) {
@@ -4941,8 +4904,7 @@ int get_smi_aperf_mperf(unsigned int cpu, struct thread_data *t)const ssize_t actual_read_size =read (mci->fd_perf, &perf_data[0 ],sizeof (perf_data));if (actual_read_size != expected_read_size) -err (-1 ,"%s: failed to read perf_data (%zu %zu)" , __func__, expected_read_size, - actual_read_size); +err (-1 ,"%s: failed to read perf_data (%zu %zu)" , __func__, expected_read_size, actual_read_size); }for (unsigned int i =0 , pi =1 ; i <NUM_MSR_COUNTERS ; ++i) {
@@ -5255,48 +5217,39 @@ char *pkg_cstate_limit_strings[] = { "unknown", "reserved", "pc0", "pc1", "pc2","pc3" ,"pc4" ,"pc6" ,"pc6n" ,"pc6r" ,"pc7" ,"pc7s" ,"pc8" ,"pc9" ,"pc10" ,"unlimited" }; -int nhm_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__1 ,PCL__3 ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int nhm_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__1 ,PCL__3 ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int snb_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCL__7 ,PCL_7S ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int snb_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCL__7 ,PCL_7S ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int hsw_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__2 ,PCL__3 ,PCL__6 ,PCL__7 ,PCL_7S ,PCL__8 ,PCL__9 ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int hsw_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__2 ,PCL__3 ,PCL__6 ,PCL__7 ,PCL_7S ,PCL__8 ,PCL__9 ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int slv_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__1 ,PCLRSV ,PCLRSV ,PCL__4 ,PCLRSV ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int slv_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__1 ,PCLRSV ,PCLRSV ,PCL__4 ,PCLRSV ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCL__6 ,PCL__7 }; -int amt_pkg_cstate_limits[16 ] = - {PCLUNL ,PCL__1 ,PCL__2 ,PCLRSV ,PCLRSV ,PCLRSV ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int amt_pkg_cstate_limits[16 ] = {PCLUNL ,PCL__1 ,PCL__2 ,PCLRSV ,PCLRSV ,PCLRSV ,PCL__6 ,PCL__7 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int phi_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int phi_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int glm_pkg_cstate_limits[16 ] = - {PCLUNL ,PCL__1 ,PCL__3 ,PCL__6 ,PCL__7 ,PCL_7S ,PCL__8 ,PCL__9 ,PCL_10 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int glm_pkg_cstate_limits[16 ] = {PCLUNL ,PCL__1 ,PCL__3 ,PCL__6 ,PCL__7 ,PCL_7S ,PCL__8 ,PCL__9 ,PCL_10 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int skx_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int skx_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__2 ,PCL_6N ,PCL_6R ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV }; -int icx_pkg_cstate_limits[16 ] = - {PCL__0 ,PCL__2 ,PCL__6 ,PCL__6 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV , +int icx_pkg_cstate_limits[16 ] = {PCL__0 ,PCL__2 ,PCL__6 ,PCL__6 ,PCLRSV ,PCLRSV ,PCLRSV ,PCLUNL ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV ,PCLRSV };
@@ -5371,8 +5324,7 @@ static void dump_power_ctl(void)return ;get_msr (base_cpu,MSR_IA32_POWER_CTL , &msr); -fprintf (outf,"cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n" , - base_cpu, msr, msr &0x2 ?"EN" :"DIS" ); +fprintf (outf,"cpu%d: MSR_IA32_POWER_CTL: 0x%08llx (C1E auto-promotion: %sabled)\n" , base_cpu, msr, msr &0x2 ?"EN" :"DIS" );/* C-state Pre-wake Disable (CSTATE_PREWAKE_DISABLE) */ if (platform->has_cst_prewake_bit)
@@ -5465,8 +5417,7 @@ static void dump_turbo_ratio_limits(int trl_msr_offset) ratio = (msr >> shift) &0xFF ; group_size = (core_counts >> shift) &0xFF ;if (ratio) -fprintf (outf,"%d * %.1f = %.1f MHz max turbo %d active cores\n" , - ratio, bclk, ratio * bclk, group_size); +fprintf (outf,"%d * %.1f = %.1f MHz max turbo %d active cores\n" , ratio, bclk, ratio * bclk, group_size); }return ;
@@ -5564,9 +5515,7 @@ static void dump_knl_turbo_ratio_limits(void)for (i = buckets_no -1 ; i >=0 ; i--)if (i >0 ? ratio[i] != ratio[i -1 ] :1 ) -fprintf (outf, -"%d * %.1f = %.1f MHz max turbo %d active cores\n" , - ratio[i], bclk, ratio[i] * bclk, cores[i]); +fprintf (outf,"%d * %.1f = %.1f MHz max turbo %d active cores\n" , ratio[i], bclk, ratio[i] * bclk, cores[i]); }static void dump_cst_cfg (void )
@@ -5651,43 +5600,37 @@ void print_irtl(void)if (platform->supported_cstates &PC3 ) {get_msr (base_cpu,MSR_PKGC3_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC3_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); }if (platform->supported_cstates &PC6 ) {get_msr (base_cpu,MSR_PKGC6_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC6_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); }if (platform->supported_cstates &PC7 ) {get_msr (base_cpu,MSR_PKGC7_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC7_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); }if (platform->supported_cstates &PC8 ) {get_msr (base_cpu,MSR_PKGC8_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC8_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); }if (platform->supported_cstates &PC9 ) {get_msr (base_cpu,MSR_PKGC9_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC9_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); }if (platform->supported_cstates &PC10 ) {get_msr (base_cpu,MSR_PKGC10_IRTL , &msr);fprintf (outf,"cpu%d: MSR_PKGC10_IRTL: 0x%08llx (" , base_cpu, msr); -fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , - (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); +fprintf (outf,"%svalid, %lld ns)\n" , msr & (1 <<15 ) ?"" :"NOT" , (msr &0x3FF ) * irtl_time_units[(msr >>10 ) &0x3 ]); } }
@@ -6221,8 +6164,7 @@ void re_initialize(void)perf_llc_init ();added_perf_counters_init ();pmt_init (); -fprintf (outf,"turbostat: re-initialized with num_cpus %d, allowed_cpus %d\n" , topo.num_cpus, - topo.allowed_cpus); +fprintf (outf,"turbostat: re-initialized with num_cpus %d, allowed_cpus %d\n" , topo.num_cpus, topo.allowed_cpus); }void set_max_cpu_num (void )
@@ -6798,8 +6740,8 @@ int probe_dev_msr(void)struct stat sb;char pathname[32 ]; -sprintf (pathname,"/dev/msr%d" , base_cpu); -return !stat (pathname, &sb); +sprintf (pathname,"/dev/msr%d" , base_cpu); +return !stat (pathname, &sb); }int probe_dev_cpu_msr (void )
@@ -7013,8 +6955,7 @@ static void probe_intel_uncore_frequency_legacy(void)int k, l;char path_base[128 ]; -sprintf (path_base,"/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d" , i, - j); +sprintf (path_base,"/sys/devices/system/cpu/intel_uncore_frequency/package_%02d_die_%02d" , i, j);sprintf (path,"%s/current_freq_khz" , path_base);if (access (path,R_OK ))
@@ -7097,8 +7038,7 @@ static void probe_intel_uncore_frequency_cluster(void)*/ if BIC_IS_ENABLED (BIC_UNCORE_MHZ ) -add_counter (0 , path, name_buf,0 ,SCOPE_PACKAGE ,COUNTER_K2M ,FORMAT_AVERAGE ,0 , - package_id); +add_counter (0 , path, name_buf,0 ,SCOPE_PACKAGE ,COUNTER_K2M ,FORMAT_AVERAGE ,0 , package_id);if (quiet)continue ;
@@ -7107,8 +7047,7 @@ static void probe_intel_uncore_frequency_cluster(void) k =read_sysfs_int (path);sprintf (path,"%s/max_freq_khz" , path_base); l =read_sysfs_int (path); -fprintf (outf,"Uncore Frequency package%d domain%d cluster%d: %d - %d MHz " , package_id, domain_id, - cluster_id, k /1000 , l /1000 ); +fprintf (outf,"Uncore Frequency package%d domain%d cluster%d: %d - %d MHz " , package_id, domain_id, cluster_id, k /1000 , l /1000 );sprintf (path,"%s/initial_min_freq_khz" , path_base); k =read_sysfs_int (path);
@@ -7170,21 +7109,17 @@ static void probe_graphics(void)else goto next; -set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms" , - gt0_is_gt ? GFX_rc6 : SAM_mc6); +set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt0/gtidle/idle_residency_ms" , gt0_is_gt ? GFX_rc6 : SAM_mc6);set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt0/freq0/cur_freq" , gt0_is_gt ? GFX_MHz : SAM_MHz); -set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq" , - gt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz); +set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt0/freq0/act_freq" , gt0_is_gt ? GFX_ACTMHz : SAM_ACTMHz); -set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms" , - gt0_is_gt ? SAM_mc6 : GFX_rc6); +set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt1/gtidle/idle_residency_ms" , gt0_is_gt ? SAM_mc6 : GFX_rc6);set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt1/freq0/cur_freq" , gt0_is_gt ? SAM_MHz : GFX_MHz); -set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq" , - gt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz); +set_graphics_fp ("/sys/class/drm/card0/device/tile0/gt1/freq0/act_freq" , gt0_is_gt ? SAM_ACTMHz : GFX_ACTMHz); goto end; }
@@ -7439,8 +7374,7 @@ int print_hwp(PER_THREAD_PARAMS)"(high %d guar %d eff %d low %d)\n" , cpu, msr, (unsigned int )HWP_HIGHEST_PERF (msr), - (unsigned int )HWP_GUARANTEED_PERF (msr), - (unsigned int)HWP_MOSTEFFICIENT_PERF(msr), (unsigned int)HWP_LOWEST_PERF(msr)); + (unsigned int)HWP_GUARANTEED_PERF(msr), (unsigned int)HWP_MOSTEFFICIENT_PERF(msr), (unsigned int)HWP_LOWEST_PERF(msr));if (get_msr (cpu,MSR_HWP_REQUEST , &msr))return 0 ;
@@ -7451,8 +7385,7 @@ int print_hwp(PER_THREAD_PARAMS) (unsigned int )(((msr) >>0 ) &0xff ), (unsigned int )(((msr) >>8 ) &0xff ), (unsigned int )(((msr) >>16 ) &0xff ), - (unsigned int )(((msr) >>24 ) &0xff ), - (unsigned int)(((msr) >> 32) & 0xff3), (unsigned int)(((msr) >> 42) & 0x1)); + (unsigned int)(((msr) >> 24) & 0xff), (unsigned int)(((msr) >> 32) & 0xff3), (unsigned int)(((msr) >> 42) & 0x1));if (has_hwp_pkg) {if (get_msr (cpu,MSR_HWP_REQUEST_PKG , &msr))
@@ -7463,23 +7396,20 @@ int print_hwp(PER_THREAD_PARAMS) cpu, msr, (unsigned int )(((msr) >>0 ) &0xff ), (unsigned int )(((msr) >>8 ) &0xff ), - (unsigned int )(((msr) >>16 ) &0xff ), - (unsigned int)(((msr) >> 24) & 0xff), (unsigned int)(((msr) >> 32) & 0xff3)); + (unsigned int)(((msr) >> 16) & 0xff), (unsigned int)(((msr) >> 24) & 0xff), (unsigned int)(((msr) >> 32) & 0xff3)); }if (has_hwp_notify) {if (get_msr (cpu,MSR_HWP_INTERRUPT , &msr))return 0 ;fprintf (outf,"cpu%d: MSR_HWP_INTERRUPT: 0x%08llx " -"(%s_Guaranteed_Perf_Change, %s_Excursion_Min)\n" , - cpu, msr, ((msr) &0x1 ) ?"EN" :"Dis" , ((msr) &0x2 ) ?"EN" :"Dis" ); +"(%s_Guaranteed_Perf_Change, %s_Excursion_Min)\n" , cpu, msr, ((msr) &0x1 ) ?"EN" :"Dis" , ((msr) &0x2 ) ?"EN" :"Dis" ); }if (get_msr (cpu,MSR_HWP_STATUS , &msr))return 0 ;fprintf (outf,"cpu%d: MSR_HWP_STATUS: 0x%08llx " -"(%sGuaranteed_Perf_Change, %sExcursion_Min)\n" , - cpu, msr, ((msr) &0x1 ) ?"" :"No-" , ((msr) &0x4 ) ?"" :"No-" ); +"(%sGuaranteed_Perf_Change, %sExcursion_Min)\n" , cpu, msr, ((msr) &0x1 ) ?"" :"No-" , ((msr) &0x4 ) ?"" :"No-" );return 0 ; }
@@ -7524,8 +7454,7 @@ int print_perf_limit(PER_THREAD_PARAMS) (msr &1 <<6 ) ?"VR-Therm, " :"" , (msr &1 <<5 ) ?"Auto-HWP, " :"" , (msr &1 <<4 ) ?"Graphics, " :"" , - (msr &1 <<2 ) ?"bit2, " :"" , - (msr & 1 << 1) ? "ThermStatus, " : "", (msr & 1 << 0) ? "PROCHOT, " : ""); + (msr & 1 << 2) ? "bit2, " : "", (msr & 1 << 1) ? "ThermStatus, " : "", (msr & 1 << 0) ? "PROCHOT, " : ""); fprintf(outf, " (Logged: %s%s%s%s%s%s%s%s%s%s%s%s%s%s)\n", (msr & 1 << 31) ? "bit31, " : "", (msr & 1 << 30) ? "bit30, " : "",
@@ -7538,8 +7467,7 @@ int print_perf_limit(PER_THREAD_PARAMS) (msr &1 <<22 ) ?"VR-Therm, " :"" , (msr &1 <<21 ) ?"Auto-HWP, " :"" , (msr &1 <<20 ) ?"Graphics, " :"" , - (msr &1 <<18 ) ?"bit18, " :"" , - (msr & 1 << 17) ? "ThermStatus, " : "", (msr & 1 << 16) ? "PROCHOT, " : ""); + (msr & 1 << 18) ? "bit18, " : "", (msr & 1 << 17) ? "ThermStatus, " : "", (msr & 1 << 16) ? "PROCHOT, " : ""); }if (platform->plr_msrs &PLR_GFX ) {
@@ -7551,16 +7479,14 @@ int print_perf_limit(PER_THREAD_PARAMS) (msr &1 <<4 ) ?"Graphics, " :"" , (msr &1 <<6 ) ?"VR-Therm, " :"" , (msr &1 <<8 ) ?"Amps, " :"" , - (msr &1 <<9 ) ?"GFXPwr, " :"" , - (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : ""); + (msr & 1 << 9) ? "GFXPwr, " : "", (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : "");fprintf (outf," (Logged: %s%s%s%s%s%s%s%s)\n" , (msr &1 <<16 ) ?"PROCHOT, " :"" , (msr &1 <<17 ) ?"ThermStatus, " :"" , (msr &1 <<20 ) ?"Graphics, " :"" , (msr &1 <<22 ) ?"VR-Therm, " :"" , (msr &1 <<24 ) ?"Amps, " :"" , - (msr &1 <<25 ) ?"GFXPwr, " :"" , - (msr &1 <<26 ) ?"PkgPwrL1, " :"" , (msr &1 <<27 ) ?"PkgPwrL2, " :"" ); + (msr &1 <<25 ) ?"GFXPwr, " :"" , (msr &1 <<26 ) ?"PkgPwrL1, " :"" , (msr &1 <<27 ) ?"PkgPwrL2, " :"" ); }if (platform->plr_msrs &PLR_RING ) {get_msr (cpu,MSR_RING_PERF_LIMIT_REASONS , &msr);
@@ -7569,14 +7495,12 @@ int print_perf_limit(PER_THREAD_PARAMS) (msr &1 <<0 ) ?"PROCHOT, " :"" , (msr &1 <<1 ) ?"ThermStatus, " :"" , (msr &1 <<6 ) ?"VR-Therm, " :"" , - (msr &1 <<8 ) ?"Amps, " :"" , - (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : ""); + (msr & 1 << 8) ? "Amps, " : "", (msr & 1 << 10) ? "PkgPwrL1, " : "", (msr & 1 << 11) ? "PkgPwrL2, " : "");fprintf (outf," (Logged: %s%s%s%s%s%s)\n" , (msr &1 <<16 ) ?"PROCHOT, " :"" , (msr &1 <<17 ) ?"ThermStatus, " :"" , (msr &1 <<22 ) ?"VR-Therm, " :"" , - (msr &1 <<24 ) ?"Amps, " :"" , - (msr &1 <<26 ) ?"PkgPwrL1, " :"" , (msr &1 <<27 ) ?"PkgPwrL2, " :"" ); + (msr &1 <<24 ) ?"Amps, " :"" , (msr &1 <<26 ) ?"PkgPwrL1, " :"" , (msr &1 <<27 ) ?"PkgPwrL2, " :"" ); }return 0 ; }
@@ -7704,8 +7628,7 @@ void print_power_limit_msr(int cpu, unsigned long long msr, char *label) cpu, label, ((msr >>15 ) &1 ) ?"EN" :"DIS" , ((msr >>0 ) &0x7FFF ) * rapl_power_units, - (1.0 + (((msr >>22 ) &0x3 ) /4.0 )) * (1 << ((msr >>17 ) &0x1F )) * rapl_time_units, - (((msr >> 16) & 1) ? "EN" : "DIS")); + (1.0 + (((msr >> 22) & 0x3) / 4.0)) * (1 << ((msr >> 17) & 0x1F)) * rapl_time_units, (((msr >> 16) & 1) ? "EN" : "DIS"));return ; }
@@ -7906,8 +7829,7 @@ int print_rapl(PER_THREAD_PARAMS) cpu, msr, ((msr >>0 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, ((msr >>16 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, - ((msr >>32 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, - ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); + ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); }if (valid_rapl_msrs &RAPL_PKG ) {
@@ -7915,16 +7837,14 @@ int print_rapl(PER_THREAD_PARAMS)if (get_msr (cpu,MSR_PKG_POWER_LIMIT , &msr))return -9 ; -fprintf (outf,"cpu%d: MSR_PKG_POWER_LIMIT: 0x%08llx (%slocked)\n" , - cpu, msr, (msr >>63 ) &1 ?"" :"UN" ); +fprintf (outf,"cpu%d: MSR_PKG_POWER_LIMIT: 0x%08llx (%slocked)\n" , cpu, msr, (msr >>63 ) &1 ?"" :"UN" );print_power_limit_msr (cpu, msr,"PKG Limit #1" );fprintf (outf,"cpu%d: PKG Limit #2: %sabled (%0.3f Watts, %f* sec, clamp %sabled)\n" , cpu, ((msr >>47 ) &1 ) ?"EN" :"DIS" , ((msr >>32 ) &0x7FFF ) * rapl_power_units, - (1.0 + (((msr >>54 ) &0x3 ) /4.0 )) * (1 << ((msr >>49 ) &0x1F )) * rapl_time_units, - ((msr >>48 ) &1 ) ?"EN" :"DIS" ); + (1.0 + (((msr >>54 ) &0x3 ) /4.0 )) * (1 << ((msr >>49 ) &0x1F )) * rapl_time_units, ((msr >>48 ) &1 ) ?"EN" :"DIS" );if (get_msr (cpu,MSR_VR_CURRENT_CONFIG , &msr))return -9 ;
@@ -7942,14 +7862,12 @@ int print_rapl(PER_THREAD_PARAMS) cpu, msr, ((msr >>0 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, ((msr >>16 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, - ((msr >>32 ) &RAPL_POWER_GRANULARITY ) * rapl_power_units, - ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); + ((msr >> 32) & RAPL_POWER_GRANULARITY) * rapl_power_units, ((msr >> 48) & RAPL_TIME_GRANULARITY) * rapl_time_units); }if (valid_rapl_msrs &RAPL_DRAM ) {if (get_msr (cpu,MSR_DRAM_POWER_LIMIT , &msr))return -9 ; -fprintf (outf,"cpu%d: MSR_DRAM_POWER_LIMIT: 0x%08llx (%slocked)\n" , - cpu, msr, (msr >>31 ) &1 ?"" :"UN" ); +fprintf (outf,"cpu%d: MSR_DRAM_POWER_LIMIT: 0x%08llx (%slocked)\n" , cpu, msr, (msr >>31 ) &1 ?"" :"UN" );print_power_limit_msr (cpu, msr,"DRAM Limit" ); }
@@ -7962,8 +7880,7 @@ int print_rapl(PER_THREAD_PARAMS)if (valid_rapl_msrs &RAPL_CORE_POWER_LIMIT ) {if (get_msr (cpu,MSR_PP0_POWER_LIMIT , &msr))return -9 ; -fprintf (outf,"cpu%d: MSR_PP0_POWER_LIMIT: 0x%08llx (%slocked)\n" , - cpu, msr, (msr >>31 ) &1 ?"" :"UN" ); +fprintf (outf,"cpu%d: MSR_PP0_POWER_LIMIT: 0x%08llx (%slocked)\n" , cpu, msr, (msr >>31 ) &1 ?"" :"UN" );print_power_limit_msr (cpu, msr,"Cores Limit" ); }if (valid_rapl_msrs &RAPL_GFX ) {
@@ -7974,8 +7891,7 @@ int print_rapl(PER_THREAD_PARAMS)if (get_msr (cpu,MSR_PP1_POWER_LIMIT , &msr))return -9 ; -fprintf (outf,"cpu%d: MSR_PP1_POWER_LIMIT: 0x%08llx (%slocked)\n" , - cpu, msr, (msr >>31 ) &1 ?"" :"UN" ); +fprintf (outf,"cpu%d: MSR_PP1_POWER_LIMIT: 0x%08llx (%slocked)\n" , cpu, msr, (msr >>31 ) &1 ?"" :"UN" );print_power_limit_msr (cpu, msr,"GFX Limit" ); }return 0 ;
@@ -8015,7 +7931,7 @@ void probe_rapl_msrs(void)return ; } - valid_rapl_msrs = platform->plat_rapl_msrs;/* success */ + valid_rapl_msrs = platform->plat_rapl_msrs;/* success */ }/*
@@ -8161,8 +8077,7 @@ int print_thermal(PER_THREAD_PARAMS) dts = (msr >>16 ) &0x7F ; dts2 = (msr >>8 ) &0x7F ; -fprintf (outf,"cpu%d: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n" , - cpu, msr, tj_max - dts, tj_max - dts2); +fprintf (outf,"cpu%d: MSR_IA32_PACKAGE_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n" , cpu, msr, tj_max - dts, tj_max - dts2); }if (do_dts && debug) {
@@ -8173,16 +8088,14 @@ int print_thermal(PER_THREAD_PARAMS) dts = (msr >>16 ) &0x7F ; resolution = (msr >>27 ) &0xF ; -fprintf (outf,"cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n" , - cpu, msr, tj_max - dts, resolution); +fprintf (outf,"cpu%d: MSR_IA32_THERM_STATUS: 0x%08llx (%d C +/- %d)\n" , cpu, msr, tj_max - dts, resolution);if (get_msr (cpu,MSR_IA32_THERM_INTERRUPT , &msr))return 0 ; dts = (msr >>16 ) &0x7F ; dts2 = (msr >>8 ) &0x7F ; -fprintf (outf,"cpu%d: MSR_IA32_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n" , - cpu, msr, tj_max - dts, tj_max - dts2); +fprintf (outf,"cpu%d: MSR_IA32_THERM_INTERRUPT: 0x%08llx (%d C, %d C)\n" , cpu, msr, tj_max - dts, tj_max - dts2); }return 0 ;
@@ -8256,8 +8169,7 @@ void decode_misc_enable_msr(void) msr &MSR_IA32_MISC_ENABLE_TM1 ?"" :"No-" , msr &MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP ?"" :"No-" , msr &MSR_IA32_MISC_ENABLE_MWAIT ?"" :"No-" , - msr &MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ?"No-" :"" , - msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); + msr & MSR_IA32_MISC_ENABLE_PREFETCH_DISABLE ? "No-" : "", msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ? "No-" : ""); }void decode_misc_feature_control (void )
@@ -8296,8 +8208,7 @@ void decode_misc_pwr_mgmt_msr(void)if (!get_msr (base_cpu,MSR_MISC_PWR_MGMT , &msr))fprintf (outf,"cpu%d: MSR_MISC_PWR_MGMT: 0x%08llx (%sable-EIST_Coordination %sable-EPB %sable-OOB)\n" , - base_cpu, msr, - msr & (1 <<0 ) ?"DIS" :"EN" , msr & (1 <<1 ) ?"EN" :"DIS" , msr & (1 <<8 ) ?"EN" :"DIS" ); + base_cpu, msr, msr & (1 <<0 ) ?"DIS" :"EN" , msr & (1 <<1 ) ?"EN" :"DIS" , msr & (1 <<8 ) ?"EN" :"DIS" ); }/*
@@ -8369,8 +8280,7 @@ static int has_perf_instr_count_access(void)return (fd !=-1 ); } -int add_rapl_perf_counter (int cpu,struct rapl_counter_info_t *rci,const struct rapl_counter_arch_info *cai, -double *scale_,enum rapl_unit *unit_) +int add_rapl_perf_counter (int cpu,struct rapl_counter_info_t *rci,const struct rapl_counter_arch_info *cai,double *scale_,enum rapl_unit *unit_) {int ret =-1 ;
@@ -8763,8 +8673,7 @@ void cstate_perf_init_(bool soft_c1) cci->source[cai->rci_index] =COUNTER_SOURCE_PERF ;/* User MSR for this counter */ - }else if (pkg_cstate_limit >= cai->pkg_cstate_limit - &&add_msr_counter (cpu, cai->msr) >=0 ) { + }else if (pkg_cstate_limit >= cai->pkg_cstate_limit &&add_msr_counter (cpu, cai->msr) >=0 ) { cci->source[cai->rci_index] =COUNTER_SOURCE_MSR ; cci->msr[cai->rci_index] = cai->msr; }
@@ -8882,8 +8791,7 @@ void process_cpuid() hygon_genuine =1 ;if (!quiet) -fprintf (outf,"CPUID(0): %.4s%.4s%.4s 0x%x CPUID levels\n" , - (char *)&ebx, (char *)&edx, (char *)&ecx, max_level); +fprintf (outf,"CPUID(0): %.4s%.4s%.4s 0x%x CPUID levels\n" , (char *)&ebx, (char *)&edx, (char *)&ecx, max_level);__cpuid (1 , fms, ebx, ecx, edx); family = (fms >>8 ) &0xf ;
@@ -8912,8 +8820,7 @@ void process_cpuid()__cpuid (0x80000000 , max_extended_level, ebx, ecx, edx);if (!quiet) { -fprintf (outf,"CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)" , - family, model, stepping, family, model, stepping); +fprintf (outf,"CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)" , family, model, stepping, family, model, stepping);if (ucode_patch_valid)fprintf (outf," microcode 0x%x" , (unsigned int )((ucode_patch >>32 ) &0xFFFFFFFF ));fputc ('\n' , outf);
@@ -8927,8 +8834,7 @@ void process_cpuid() ecx_flags & (1 <<8 ) ?"TM2" :"-" , edx_flags & (1 <<4 ) ?"TSC" :"-" , edx_flags & (1 <<5 ) ?"MSR" :"-" , - edx_flags & (1 <<22 ) ?"ACPI-TM" :"-" , - edx_flags & (1 << 28) ? "HT" : "-", edx_flags & (1 << 29) ? "TM" : "-"); + edx_flags & (1 << 22) ? "ACPI-TM" : "-", edx_flags & (1 << 28) ? "HT" : "-", edx_flags & (1 << 29) ? "TM" : "-"); }probe_platform_features (family, model);
@@ -8976,8 +8882,7 @@ void process_cpuid() do_ptm ?"" :"No-" , has_hwp ?"" :"No-" , has_hwp_notify ?"" :"No-" , - has_hwp_activity_window ?"" :"No-" , - has_hwp_epp ? "" : "No-", has_hwp_pkg ? "" : "No-", has_epb ? "" : "No-"); + has_hwp_activity_window ? "" : "No-", has_hwp_epp ? "" : "No-", has_hwp_pkg ? "" : "No-", has_epb ? "" : "No-");if (!quiet)decode_misc_enable_msr ();
@@ -9011,8 +8916,7 @@ void process_cpuid()if (ebx_tsc !=0 ) {if (!quiet && (ebx !=0 )) -fprintf (outf,"CPUID(0x15): eax_crystal: %d ebx_tsc: %d ecx_crystal_hz: %d\n" , - eax_crystal, ebx_tsc, crystal_hz); +fprintf (outf,"CPUID(0x15): eax_crystal: %d ebx_tsc: %d ecx_crystal_hz: %d\n" , eax_crystal, ebx_tsc, crystal_hz);if (crystal_hz ==0 ) crystal_hz = platform->crystal_freq;
@@ -9044,8 +8948,7 @@ void process_cpuid() tsc_tweak = base_hz / tsc_hz;if (!quiet) -fprintf (outf,"CPUID(0x16): base_mhz: %d max_mhz: %d bus_mhz: %d\n" , - base_mhz, max_mhz, bus_mhz); +fprintf (outf,"CPUID(0x16): base_mhz: %d max_mhz: %d bus_mhz: %d\n" , base_mhz, max_mhz, bus_mhz); }if (cpuid_has_aperf_mperf)
@@ -9709,8 +9612,7 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo) perf_config =read_perf_config (perf_device, pinfo->event);if (perf_config == (unsigned int )-1 ) { -warnx ("%s: perf/%s/%s: failed to read %s" , - __func__, perf_device, pinfo->event,"config" ); +warnx ("%s: perf/%s/%s: failed to read %s" , __func__, perf_device, pinfo->event,"config" );continue ; }
@@ -9721,8 +9623,7 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo) fd_perf =open_perf_counter (cpu, perf_type, perf_config,-1 ,0 );if (fd_perf ==-1 ) { -warnx ("%s: perf/%s/%s: failed to open counter on cpu%d" , - __func__, perf_device, pinfo->event, cpu); +warnx ("%s: perf/%s/%s: failed to open counter on cpu%d" , __func__, perf_device, pinfo->event, cpu);continue ; }
@@ -9731,8 +9632,7 @@ int added_perf_counters_init_(struct perf_counter_info *pinfo) pinfo->scale = perf_scale;if (debug) -fprintf (stderr,"Add perf/%s/%s cpu%d: %d\n" , - perf_device, pinfo->event, cpu, pinfo->fd_perf_per_domain[next_domain]); +fprintf (stderr,"Add perf/%s/%s cpu%d: %d\n" , perf_device, pinfo->event, cpu, pinfo->fd_perf_per_domain[next_domain]); } pinfo = pinfo->next;
@@ -10046,8 +9946,7 @@ int pmt_add_counter(unsigned int guid, unsigned int seq, const char *name, enum }if (conflict) { -fprintf (stderr,"%s: conflicting parameters for the PMT counter with the same name %s\n" , - __func__, name); +fprintf (stderr,"%s: conflicting parameters for the PMT counter with the same name %s\n" , __func__, name);exit (1 ); }
@@ -10090,8 +9989,7 @@ void pmt_init(void)* CWF with newer firmware might require a PMT_TYPE_XTAL_TIME intead of PMT_TYPE_TCORE_CLOCK. */ pmt_add_counter (PMT_CWF_MC1E_GUID , seq,"CPU%c1e" ,PMT_TYPE_TCORE_CLOCK , -PMT_COUNTER_CWF_MC1E_LSB ,PMT_COUNTER_CWF_MC1E_MSB , offset,SCOPE_CPU , -FORMAT_DELTA , cpu_num,PMT_OPEN_TRY ); +PMT_COUNTER_CWF_MC1E_LSB ,PMT_COUNTER_CWF_MC1E_MSB , offset,SCOPE_CPU ,FORMAT_DELTA , cpu_num,PMT_OPEN_TRY );/* * Rather complex logic for each time we go to the next loop iteration,
@@ -10287,8 +10185,7 @@ struct msr_counter *find_msrp_by_name(struct msr_counter *head, char *name) }int add_counter (unsigned int msr_num,char *path,char *name, -unsigned int width,enum counter_scope scope, -enum counter_type type,enum counter_format format,int flags,int id) +unsigned int width,enum counter_scope scope,enum counter_type type,enum counter_format format,int flags,int id) {struct msr_counter *msrp;
@@ -10397,9 +10294,7 @@ int add_counter(unsigned int msr_num, char *path, char *name,struct perf_counter_info *make_perf_counter_info (const char *perf_device,const char *perf_event,const char *name, -unsigned int width, -enum counter_scope scope, -enum counter_type type,enum counter_format format) +unsigned int width,enum counter_scope scope,enum counter_type type,enum counter_format format) {struct perf_counter_info *pinfo;
@@ -10474,8 +10369,7 @@ int add_perf_counter(const char *perf_device, const char *perf_event, const char// FIXME: we might not have debug here yet if (debug) -fprintf (stderr,"%s: %s/%s, name: %s, scope%d\n" , - __func__, pinfo->device, pinfo->event, pinfo->name, pinfo->scope); +fprintf (stderr,"%s: %s/%s, name: %s, scope%d\n" , __func__, pinfo->device, pinfo->event, pinfo->name, pinfo->scope);return 0 ; }
@@ -10644,8 +10538,7 @@ int pmt_parse_from_path(const char *target_path, unsigned int *out_guid, unsignepmt_diriter_init (&pmt_iter); -for (dirname =pmt_diriter_begin (&pmt_iter,SYSFS_TELEM_PATH ); dirname !=NULL ; - dirname =pmt_diriter_next (&pmt_iter)) { +for (dirname =pmt_diriter_begin (&pmt_iter,SYSFS_TELEM_PATH ); dirname !=NULL ; dirname =pmt_diriter_next (&pmt_iter)) { fd_telem_dir =openat (dirfd (pmt_iter.dir), dirname->d_name,O_RDONLY |O_DIRECTORY );if (fd_telem_dir ==-1 )
@@ -10657,8 +10550,7 @@ int pmt_parse_from_path(const char *target_path, unsigned int *out_guid, unsigne }if (fstat (fd_telem_dir, &stat) ==-1 ) { -fprintf (stderr,"%s: Failed to stat %s directory: %s" , __func__, - dirname->d_name,strerror (errno)); +fprintf (stderr,"%s: Failed to stat %s directory: %s" , __func__, dirname->d_name,strerror (errno));continue ; }
@@ -10754,8 +10646,7 @@ void parse_add_command_pmt(char *add_command) }if (!has_scope) { -printf ("%s: invalid value for scope. Expected cpu%%u, core%%u or package%%u.\n" , - __func__); +printf ("%s: invalid value for scope. Expected cpu%%u, core%%u or package%%u.\n" , __func__);exit (1 ); }
@@ -10831,8 +10722,7 @@ void parse_add_command_pmt(char *add_command) }if (!has_format) { -fprintf (stderr,"%s: Invalid format %s. Expected raw, average or delta\n" , - __func__, format_name); +fprintf (stderr,"%s: Invalid format %s. Expected raw, average or delta\n" , __func__, format_name);exit (1 ); } }
Signature · 1 line
2.45.2