Skip to content

Commit e172f1e

Browse files
committed
Merge tag 'v6.11-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat updates from Len Brown: - Enable turbostat extensions to add both perf and PMT (Intel Platform Monitoring Technology) counters via the cmdline - Demonstrate PMT access with built-in support for Meteor Lake's Die C6 counter * tag 'v6.11-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: tools/power turbostat: version 2024.07.26 tools/power turbostat: Include umask=%x in perf counter's config tools/power turbostat: Document PMT in turbostat.8 tools/power turbostat: Add MTL's PMT DC6 builtin counter tools/power turbostat: Add early support for PMT counters tools/power turbostat: Add selftests for added perf counters tools/power turbostat: Add selftests for SMI, APERF and MPERF counters tools/power turbostat: Move verbose counter messages to level 2 tools/power turbostat: Move debug prints from stdout to stderr tools/power turbostat: Fix typo in turbostat.8 tools/power turbostat: Add perf added counter example to turbostat.8 tools/power turbostat: Fix formatting in turbostat.8 tools/power turbostat: Extend --add option with perf counters tools/power turbostat: Group SMI counter with APERF and MPERF tools/power turbostat: Add ZERO_ARRAY for zero initializing builtin array tools/power turbostat: Replace enum rapl_source and cstate_source with counter_source tools/power turbostat: Remove anonymous union from rapl_counter_info_t tools/power/turbostat: Switch to new Intel CPU model defines
2 parents e62f81b + 866d2d3 commit e172f1e

File tree

5 files changed

+2277
-498
lines changed

5 files changed

+2277
-498
lines changed

tools/power/x86/turbostat/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ snapshot: turbostat
4646
@echo "#define GENMASK_ULL(h, l) (((~0ULL) << (l)) & (~0ULL >> (sizeof(long long) * 8 - 1 - (h))))" >> $(SNAPSHOT)/bits.h
4747

4848
@echo '#define BUILD_BUG_ON(cond) do { enum { compile_time_check ## __COUNTER__ = 1/(!(cond)) }; } while (0)' > $(SNAPSHOT)/build_bug.h
49+
@echo '#define __must_be_array(arr) 0' >> $(SNAPSHOT)/build_bug.h
4950

5051
@echo PWD=. > $(SNAPSHOT)/Makefile
5152
@echo "CFLAGS += -DMSRHEADER='\"msr-index.h\"'" >> $(SNAPSHOT)/Makefile

tools/power/x86/turbostat/turbostat.8

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ name as necessary to disambiguate it from others is necessary. Note that option
2828
.PP
2929
\fB--add attributes\fP add column with counter having specified 'attributes'. The 'location' attribute is required, all others are optional.
3030
.nf
31-
location: {\fBmsrDDD\fP | \fBmsr0xXXX\fP | \fB/sys/path...\fP}
31+
location: {\fBmsrDDD\fP | \fBmsr0xXXX\fP | \fB/sys/path...\fP | \fBperf/<device>/<event>\fP}
3232
msrDDD is a decimal offset, eg. msr16
3333
msr0xXXX is a hex offset, eg. msr0x10
3434
/sys/path... is an absolute path to a sysfs attribute
35+
<device> is a perf device from /sys/bus/event_source/devices/<device> eg. cstate_core
36+
<event> is a perf event for given device from /sys/bus/event_source/devices/<device>/events/<event> eg. c1-residency
37+
perf/cstate_core/c1-residency would then use /sys/bus/event_source/devices/cstate_core/events/c1-residency
3538

3639
scope: {\fBcpu\fP | \fBcore\fP | \fBpackage\fP}
3740
sample and print the counter for every cpu, core, or package.
@@ -52,6 +55,39 @@ name as necessary to disambiguate it from others is necessary. Note that option
5255
as the column header.
5356
.fi
5457
.PP
58+
\fB--add pmt,[attr_name=attr_value, ...]\fP add column with a PMT (Intel Platform Monitoring Technology) counter in a similar way to --add option above, but require PMT metadata to be supplied to correctly read and display the counter. The metadata can be found in the Intel PMT XML files, hosted at https://github.com/intel/Intel-PMT. For a complete example see "ADD PMT COUNTER EXAMPLE".
59+
.nf
60+
name="name_string"
61+
For column header.
62+
63+
type={\fBraw\fP}
64+
'raw' shows the counter contents in hex.
65+
default: raw
66+
67+
format={\fBraw\fP | \fBdelta\fP}
68+
'raw' shows the counter contents in hex.
69+
'delta' shows the difference in values during the measurement interval.
70+
default: raw
71+
72+
domain={\fBcpu%u\fP | \fBcore%u\fP | \fBpackage%u\fP}
73+
'cpu' per cpu/thread counter.
74+
'core' per core counter.
75+
'package' per package counter.
76+
'%u' denotes id of the domain that the counter is associated with. For example core4 would mean that the counter is associated with core number 4.
77+
78+
offset=\fB%u\fP
79+
'%u' offset within the PMT MMIO region.
80+
81+
lsb=\fB%u\fP
82+
'%u' least significant bit within the 64 bit value read from 'offset'. Together with 'msb', used to form a read mask.
83+
84+
msb=\fB%u\fP
85+
'%u' most significant bit within the 64 bit value read from 'offset'. Together with 'lsb', used to form a read mask.
86+
87+
guid=\fB%x\fP
88+
'%x' hex identifier of the PMT MMIO region.
89+
.fi
90+
.PP
5591
\fB--cpu cpu-set\fP limit output to system summary plus the specified cpu-set. If cpu-set is the string "core", then the system summary plus the first CPU in each core are printed -- eg. subsequent HT siblings are not printed. Or if cpu-set is the string "package", then the system summary plus the first CPU in each package is printed. Otherwise, the system summary plus the specified set of CPUs are printed. The cpu-set is ordered from low to high, comma delimited with ".." and "-" permitted to denote a range. eg. 1,2,8,14..17,21-44
5692
.PP
5793
\fB--hide column\fP do not show the specified built-in columns. May be invoked multiple times, or with a comma-separated list of column names.
@@ -67,10 +103,10 @@ The column name "all" can be used to enable all disabled-by-default built-in cou
67103
.PP
68104
\fB--quiet\fP Do not decode and print the system configuration header information.
69105
.PP
70-
+\fB--no-msr\fP Disable all the uses of the MSR driver.
71-
+.PP
72-
+\fB--no-perf\fP Disable all the uses of the perf API.
73-
+.PP
106+
\fB--no-msr\fP Disable all the uses of the MSR driver.
107+
.PP
108+
\fB--no-perf\fP Disable all the uses of the perf API.
109+
.PP
74110
\fB--interval seconds\fP overrides the default 5.0 second measurement interval.
75111
.PP
76112
\fB--num_iterations num\fP number of the measurement iterations.
@@ -320,7 +356,7 @@ available on all processors.
320356
Here we limit turbostat to showing just the CPU number for cpu0 - cpu3.
321357
We add a counter showing the 32-bit raw value of MSR 0x199 (MSR_IA32_PERF_CTL),
322358
labeling it with the column header, "PRF_CTRL", and display it only once,
323-
afte the conclusion of a 0.1 second sleep.
359+
after the conclusion of a 0.1 second sleep.
324360
.nf
325361
sudo ./turbostat --quiet --cpu 0-3 --show CPU --add msr0x199,u32,raw,PRF_CTRL sleep .1
326362
0.101604 sec
@@ -333,6 +369,56 @@ CPU PRF_CTRL
333369

334370
.fi
335371

372+
.SH ADD PERF COUNTER EXAMPLE
373+
Here we limit turbostat to showing just the CPU number for cpu0 - cpu3.
374+
We add a counter showing time spent in C1 core cstate,
375+
labeling it with the column header, "pCPU%c1", and display it only once,
376+
after the conclusion of 0.1 second sleep.
377+
We also show CPU%c1 built-in counter that should show similar values.
378+
.nf
379+
sudo ./turbostat --quiet --cpu 0-3 --show CPU,CPU%c1 --add perf/cstate_core/c1-residency,cpu,delta,percent,pCPU%c1 sleep .1
380+
0.102448 sec
381+
CPU pCPU%c1 CPU%c1
382+
- 34.89 34.89
383+
0 45.99 45.99
384+
1 45.94 45.94
385+
2 23.83 23.83
386+
3 23.84 23.84
387+
388+
.fi
389+
390+
.SH ADD PMT COUNTER EXAMPLE
391+
Here we limit turbostat to showing just the CPU number 0.
392+
We add two counters, showing crystal clock count and the DC6 residency.
393+
All the parameters passed are based on the metadata found in the PMT XML files.
394+
395+
For the crystal clock count, we
396+
label it with the column header, "XTAL",
397+
we set the type to 'raw', to read the number of clock ticks in hex,
398+
we set the format to 'delta', to display the difference in ticks during the measurement interval,
399+
we set the domain to 'package0', to collect it and associate it with the whole package number 0,
400+
we set the offset to '0', which is a offset of the counter within the PMT MMIO region,
401+
we set the lsb and msb to cover all 64 bits of the read 64 bit value,
402+
and finally we set the guid to '0x1a067102', that identifies the PMT MMIO region to which the 'offset' is applied to read the counter value.
403+
404+
For the DC6 residency counter, we
405+
label it with the column header, "Die%c6",
406+
we set the type to 'txtal_time', to obtain the percent residency value
407+
we set the format to 'delta', to display the difference in ticks during the measurement interval,
408+
we set the domain to 'package0', to collect it and associate it with the whole package number 0,
409+
we set the offset to '0', which is a offset of the counter within the PMT MMIO region,
410+
we set the lsb and msb to cover all 64 bits of the read 64 bit value,
411+
and finally we set the guid to '0x1a067102', that identifies the PMT MMIO region to which the 'offset' is applied to read the counter value.
412+
413+
.nf
414+
sudo ./turbostat --quiet --cpu 0 --show CPU --add pmt,name=XTAL,type=raw,format=delta,domain=package0,offset=0,lsb=0,msb=63,guid=0x1a067102 --add pmt,name=Die%c6,type=txtal_time,format=delta,domain=package0,offset=120,lsb=0,msb=63,guid=0x1a067102
415+
0.104352 sec
416+
CPU XTAL Die%c6
417+
- 0x0000006d4d957ca7 0.00
418+
0 0x0000006d4d957ca7 0.00
419+
0.102448 sec
420+
.fi
421+
336422
.SH INPUT
337423

338424
For interval-mode, turbostat will immediately end the current interval

0 commit comments

Comments
 (0)