Skip to content

Commit 5149609

Browse files
committed
tools/power turbostat: version 2026.02.14
Since release 2025.12.02: Add L2 statistics columns for recent Intel processors: L2MRPS = L2 Cache M-References Per Second L2%hit = L2 Cache Hit % Sort work and output by cpu# rather than core# This commit: Version number and white space (indent -l160) No functional change. Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 96718ad commit 5149609

1 file changed

Lines changed: 21 additions & 36 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* turbostat -- show CPU frequency and C-state residency
44
* on modern Intel and AMD processors.
55
*
6-
* Copyright (c) 2025 Intel Corporation.
6+
* Copyright (c) 2010 - 2026 Intel Corporation
77
* Len Brown <len.brown@intel.com>
88
*/
99

@@ -2735,8 +2735,7 @@ void help(void)
27352735
" sets the Thermal Control Circuit temperature in\n"
27362736
" degrees Celsius\n"
27372737
" -h, --help\n"
2738-
" print this help message\n"
2739-
" -v, --version\n\t\tprint version information\n\nFor more help, run \"man turbostat\"\n");
2738+
" print this help message\n -v, --version\n\t\tprint version information\n\nFor more help, run \"man turbostat\"\n");
27402739
}
27412740

27422741
/*
@@ -3671,11 +3670,9 @@ int format_counters(PER_THREAD_PARAMS)
36713670
if (DO_BIC(BIC_RAM_J))
36723671
outp += sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&p->energy_dram, RAPL_UNIT_JOULES, interval_float));
36733672
if (DO_BIC(BIC_PKG__))
3674-
outp +=
3675-
sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&p->rapl_pkg_perf_status, RAPL_UNIT_WATTS, interval_float));
3673+
outp += sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&p->rapl_pkg_perf_status, RAPL_UNIT_WATTS, interval_float));
36763674
if (DO_BIC(BIC_RAM__))
3677-
outp +=
3678-
sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&p->rapl_dram_perf_status, RAPL_UNIT_WATTS, interval_float));
3675+
outp += sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&p->rapl_dram_perf_status, RAPL_UNIT_WATTS, interval_float));
36793676
/* UncMHz */
36803677
if (DO_BIC(BIC_UNCORE_MHZ))
36813678
outp += sprintf(outp, "%s%d", (printed++ ? delim : ""), p->uncore_mhz);
@@ -3725,11 +3722,9 @@ int format_counters(PER_THREAD_PARAMS)
37253722
}
37263723

37273724
if (DO_BIC(BIC_SysWatt) && (t == average.threads))
3728-
outp += sprintf(outp, fmt8, (printed++ ? delim : ""),
3729-
rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_WATTS, interval_float));
3725+
outp += sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_WATTS, interval_float));
37303726
if (DO_BIC(BIC_Sys_J) && (t == average.threads))
3731-
outp += sprintf(outp, fmt8, (printed++ ? delim : ""),
3732-
rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_JOULES, interval_float));
3727+
outp += sprintf(outp, fmt8, (printed++ ? delim : ""), rapl_counter_get_value(&pplat_cnt->energy_psys, RAPL_UNIT_JOULES, interval_float));
37333728

37343729
done:
37353730
if (*(outp - 1) != '\n')
@@ -3942,7 +3937,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d
39423937
/* check for TSC < 1 Mcycles over interval */
39433938
if (old->tsc < (1000 * 1000))
39443939
errx(-3, "Insanely slow TSC rate, TSC stops in idle?\n"
3945-
"You can disable all c-states by booting with \"idle=poll\"\n" "or just the deep ones with \"processor.max_cstate=1\"");
3940+
"You can disable all c-states by booting with \"idle=poll\"\nor just the deep ones with \"processor.max_cstate=1\"");
39463941

39473942
old->c1 = new->c1 - old->c1;
39483943

@@ -5546,8 +5541,7 @@ static void dump_turbo_ratio_limits(int trl_msr_offset)
55465541
int shift;
55475542

55485543
get_msr(master_cpu, trl_msr_offset, &msr);
5549-
fprintf(outf, "cpu%d: MSR_%sTURBO_RATIO_LIMIT: 0x%08llx\n",
5550-
master_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY_" : "", msr);
5544+
fprintf(outf, "cpu%d: MSR_%sTURBO_RATIO_LIMIT: 0x%08llx\n", master_cpu, trl_msr_offset == MSR_SECONDARY_TURBO_RATIO_LIMIT ? "SECONDARY_" : "", msr);
55515545

55525546
if (platform->trl_msrs & TRL_CORECOUNT) {
55535547
get_msr(master_cpu, MSR_TURBO_RATIO_LIMIT1, &core_counts);
@@ -8019,8 +8013,7 @@ int print_rapl(PER_THREAD_PARAMS)
80198013
return -1;
80208014
}
80218015

8022-
fprintf(outf, "cpu%d: %s: 0x%08llx (%f Watts, %f Joules, %f sec.)\n", cpu, msr_name, msr,
8023-
rapl_power_units, rapl_energy_units, rapl_time_units);
8016+
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);
80248017

80258018
if (valid_rapl_msrs & RAPL_PKG_POWER_INFO) {
80268019

@@ -8052,8 +8045,7 @@ int print_rapl(PER_THREAD_PARAMS)
80528045
return -9;
80538046

80548047
fprintf(outf, "cpu%d: MSR_VR_CURRENT_CONFIG: 0x%08llx\n", cpu, msr);
8055-
fprintf(outf, "cpu%d: PKG Limit #4: %f Watts (%slocked)\n",
8056-
cpu, ((msr >> 0) & 0x1FFF) * rapl_power_units, (msr >> 31) & 1 ? "" : "UN");
8048+
fprintf(outf, "cpu%d: PKG Limit #4: %f Watts (%slocked)\n", cpu, ((msr >> 0) & 0x1FFF) * rapl_power_units, (msr >> 31) & 1 ? "" : "UN");
80578049
}
80588050

80598051
if (valid_rapl_msrs & RAPL_DRAM_POWER_INFO) {
@@ -8390,8 +8382,7 @@ void decode_misc_feature_control(void)
83908382
if (!get_msr(master_cpu, MSR_MISC_FEATURE_CONTROL, &msr))
83918383
fprintf(outf,
83928384
"cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch %sL2-Prefetch-pair %sL1-Prefetch %sL1-IP-Prefetch)\n",
8393-
master_cpu, msr, msr & (0 << 0) ? "No-" : "", msr & (1 << 0) ? "No-" : "",
8394-
msr & (2 << 0) ? "No-" : "", msr & (3 << 0) ? "No-" : "");
8385+
master_cpu, msr, msr & (0 << 0) ? "No-" : "", msr & (1 << 0) ? "No-" : "", msr & (2 << 0) ? "No-" : "", msr & (3 << 0) ? "No-" : "");
83958386
}
83968387

83978388
/*
@@ -8433,12 +8424,10 @@ void decode_c6_demotion_policy_msr(void)
84338424
return;
84348425

84358426
if (!get_msr(master_cpu, MSR_CC6_DEMOTION_POLICY_CONFIG, &msr))
8436-
fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n",
8437-
master_cpu, msr, msr & (1 << 0) ? "EN" : "DIS");
8427+
fprintf(outf, "cpu%d: MSR_CC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-CC6-Demotion)\n", master_cpu, msr, msr & (1 << 0) ? "EN" : "DIS");
84388428

84398429
if (!get_msr(master_cpu, MSR_MC6_DEMOTION_POLICY_CONFIG, &msr))
8440-
fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n",
8441-
master_cpu, msr, msr & (1 << 0) ? "EN" : "DIS");
8430+
fprintf(outf, "cpu%d: MSR_MC6_DEMOTION_POLICY_CONFIG: 0x%08llx (%sable-MC6-Demotion)\n", master_cpu, msr, msr & (1 << 0) ? "EN" : "DIS");
84428431
}
84438432

84448433
void print_dev_latency(void)
@@ -8756,8 +8745,7 @@ void rapl_perf_init(void)
87568745
/* Assumes msr_counter_info is populated */
87578746
static int has_amperf_access(void)
87588747
{
8759-
return cpuid_has_aperf_mperf && msr_counter_arch_infos[MSR_ARCH_INFO_APERF_INDEX].present &&
8760-
msr_counter_arch_infos[MSR_ARCH_INFO_MPERF_INDEX].present;
8748+
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;
87618749
}
87628750

87638751
int *get_cstate_perf_group_fd(struct cstate_counter_info_t *cci, const char *group_name)
@@ -8968,8 +8956,7 @@ void cstate_perf_init_(bool soft_c1)
89688956
if (!per_core && pkg_visited[pkg_id])
89698957
continue;
89708958

8971-
const bool counter_needed = BIC_IS_ENABLED(cai->bic_number) ||
8972-
(soft_c1 && (cai->flags & CSTATE_COUNTER_FLAG_SOFT_C1_DEPENDENCY));
8959+
const bool counter_needed = BIC_IS_ENABLED(cai->bic_number) || (soft_c1 && (cai->flags & CSTATE_COUNTER_FLAG_SOFT_C1_DEPENDENCY));
89738960
const bool counter_supported = (platform->supported_cstates & cai->feature_mask);
89748961

89758962
if (counter_needed && counter_supported) {
@@ -9259,8 +9246,7 @@ void process_cpuid()
92599246
if (crystal_hz) {
92609247
tsc_hz = (unsigned long long)crystal_hz *ebx_tsc / eax_crystal;
92619248
if (!quiet)
9262-
fprintf(outf, "TSC: %lld MHz (%d Hz * %d / %d / 1000000)\n",
9263-
tsc_hz / 1000000, crystal_hz, ebx_tsc, eax_crystal);
9249+
fprintf(outf, "TSC: %lld MHz (%d Hz * %d / %d / 1000000)\n", tsc_hz / 1000000, crystal_hz, ebx_tsc, eax_crystal);
92649250
}
92659251
}
92669252
}
@@ -9645,7 +9631,7 @@ void topology_probe(bool startup)
96459631
if (cpus[i].ht_id == 0)
96469632
topo.num_cores++;
96479633
}
9648-
topo.max_core_id = max_core_id; /* within a package */
9634+
topo.max_core_id = max_core_id; /* within a package */
96499635
topo.max_package_id = max_package_id;
96509636
topo.num_cores = (max_core_id + 1) * topo.num_packages; /* per system */
96519637

@@ -9712,6 +9698,7 @@ void allocate_counters_1(struct counters *counters)
97129698
error:
97139699
err(1, "calloc counters_1");
97149700
}
9701+
97159702
void allocate_counters(struct counters *counters)
97169703
{
97179704
int i;
@@ -10368,8 +10355,7 @@ void pmt_init(void)
1036810355

1036910356
if (BIC_IS_ENABLED(BIC_Diec6)) {
1037010357
pmt_add_counter(PMT_MTL_DC6_GUID, PMT_MTL_DC6_SEQ, "Die%c6", PMT_TYPE_XTAL_TIME,
10371-
PMT_COUNTER_MTL_DC6_LSB, PMT_COUNTER_MTL_DC6_MSB, PMT_COUNTER_MTL_DC6_OFFSET,
10372-
SCOPE_PACKAGE, FORMAT_DELTA, 0, PMT_OPEN_TRY);
10358+
PMT_COUNTER_MTL_DC6_LSB, PMT_COUNTER_MTL_DC6_MSB, PMT_COUNTER_MTL_DC6_OFFSET, SCOPE_PACKAGE, FORMAT_DELTA, 0, PMT_OPEN_TRY);
1037310359
}
1037410360

1037510361
if (BIC_IS_ENABLED(BIC_CPU_c1e)) {
@@ -10547,7 +10533,7 @@ int get_and_dump_counters(void)
1054710533

1054810534
void print_version()
1054910535
{
10550-
fprintf(outf, "turbostat version 2026.02.04 - Len Brown <lenb@kernel.org>\n");
10536+
fprintf(outf, "turbostat version 2026.02.14 - Len Brown <lenb@kernel.org>\n");
1055110537
}
1055210538

1055310539
#define COMMAND_LINE_SIZE 2048
@@ -11169,8 +11155,7 @@ void parse_add_command_pmt(char *add_command)
1116911155
}
1117011156

1117111157
if (direct_path && has_guid) {
11172-
printf("%s: path and guid+seq parameters are mutually exclusive\n"
11173-
"notice: passed guid=0x%x and path=%s\n", __func__, guid, direct_path);
11158+
printf("%s: path and guid+seq parameters are mutually exclusive\nnotice: passed guid=0x%x and path=%s\n", __func__, guid, direct_path);
1117411159
exit(1);
1117511160
}
1117611161

0 commit comments

Comments
 (0)