Intel core misc PMUs support
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest9 patches 23 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | perf/x86: Add Intel core misc PMUs supportarch/ arch/ arch/ | +987 | 0 replies | |
| 2/9 | perf/x86: core_misc PMU disable and enable supportarch/ arch/ arch/ +1 more | +57 | 10 replies | |
| 3/9 | perf/x86: Add is_hardware_eventinclude/ kernel/ | +9 | 4 replies | |
| 4/9 | perf/x86: special case per-cpu core misc PMU eventsarch/ include/ include/ +2 more | +26 | 5 replies | |
| 5/9 | perf,tools: open event with it's own cpus and threadstools/ | +1 | 0 replies | |
| 6/9 | perf,tools: Dump per-sample freq in report -Dtools/ tools/ | +39 | 0 replies | |
| 7/9 | perf,tools: save APERF/MPERF/TSC in struct perf_sampletools/ tools/ | +23 | 0 replies | |
| 8/9 | perf,tools: caculate and save tsc/avg/bzy freq in he_stattools/ tools/ tools/ +4 more | +61 | 3 replies | |
| 9/9 | perf,tools: Show freq in perf report --stdiotools/ tools/ tools/ +6 more | +105 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/9] Intel core misc PMUs support
From: Kan Liang <[email protected]>
This patchkit intends to support Intel core misc PMUs. There are miscellaneous free running (read-only) counters in core. Some new PMUs called core misc PMUs are composed to include these counters. The counters include TSC, IA32_APERF, IA32_MPERF, IA32_PPERF, SMI_COUNT, CORE_C*_RESIDENCY and PKG_C*_RESIDENCY. There could be more in future platform.
Although these counters may be used simultaneously by other tools, it still make sense to implement them in perf. Because we can conveniently collect them together with other events. Furthermore, the handling of the free running counters is very different, so it makes sense to put them into separate PMUs.
Here are some useful examples.
1. the ASTATE/MSTATE/TSC events can be used to calculate the frequency during each sampling period.
$ perf record -e
{ref-cycles,core_misc/tsc/,core_misc/power-mperf/,core_misc/power-aperf/}:S
--running-time -a ~/tchain_edit$ perf report --stdio --group --show-freq
# Samples: 71K of event 'anon group { ref-cycles, core_misc/tsc/, core_misc/power-mperf/, core_misc/power-aperf/ }'
# Event count (approx.): 215265868412
#
# Overhead TSC MHz AVG MHz BZY MHz
Command Shared Object Symbol
# ................................ ......... ......... .........
............ ................ ..................................
#
98.85% 5.41% 98.89% 98.95% 2293 1474 2302
tchain_edit tchain_edit [.] f3
0.39% 1.64% 0.39% 0.37% 2295 1 3053
kworker/25:1 [kernel.vmlinux] [k] delay_tsc
0.08% 24.20% 0.07% 0.06% 2295 82 2746
swapper [kernel.vmlinux] [k] acpi_idle_do_entry
0.05% 0.00% 0.05% 0.05% 2295 2289 2295
tchain_edit tchain_edit [.] f22. Caculate the CPU%
CPU_Utilization = CPU_CLK_UNHALTED.REF_TSC / TSC
$ perf stat -x, -e "ref-cycles,core_misc/tsc/" -C0 taskset -c 0 sleep 1 3481579,,ref-cycles 2301685567,,core_misc/tsc/ The CPU% for sleep is 0.15%.
$ perf stat -x, -e "ref-cycles,core_misc/tsc/" -C0 taskset -c 0 busyloop 11924042536,,ref-cycles 11929411840,,core_misc/tsc/ The CPU% for busyloop is 99.95%
3. Caculate fraction of time when the core is running in C6 state CORE_C6_time% = CORE_C6_RESIDENCY / TSC
$ perf stat -x, -e"power_core/c6-residency/,core_misc/tsc/" -C0 -- taskset -c 0 sleep 1 2287199396,,power_core/c6-residency/ 2297755875,,core_misc/tsc/ For sleep, 99.5% of time run in C6 state.
$ perf stat -x, -e"power_core/c6-residency/,core_misc/tsc/" -C0 -- taskset -c 0 busyloop 1330044,,power_core/c6-residency/ 9932928928,,core_misc/tsc/ For busyloop, 0.01% of time run in C6 state.
Kan Liang (9):
perf/x86: Add Intel core misc PMUs support perf/x86: core_misc PMU disable and enable support perf/x86: Add is_hardware_event
perf/x86: special case per-cpu core misc PMU events perf,tools: open event with it's own cpus and threads perf,tools: Dump per-sample freq in report -D perf,tools: save APERF/MPERF/TSC in struct perf_sample perf,tools: caculate and save tsc/avg/bzy freq in he_stat perf,tools: Show freq in perf report --stdio
arch/x86/include/asm/perf_event.h | 2 + arch/x86/kernel/cpu/Makefile | 1 + arch/x86/kernel/cpu/perf_event.h | 10 + arch/x86/kernel/cpu/perf_event_intel.c | 4 + arch/x86/kernel/cpu/perf_event_intel_core_misc.c | 933 +++++++++++++++++++++++ arch/x86/kernel/cpu/perf_event_intel_core_misc.h | 96 +++ include/linux/perf_event.h | 17 +- include/linux/sched.h | 1 + include/uapi/linux/perf_event.h | 1 + kernel/events/core.c | 15 +- tools/perf/Documentation/perf-report.txt | 10 + tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-report.c | 17 + tools/perf/perf.h | 1 + tools/perf/tests/hists_link.c | 4 +- tools/perf/ui/hist.c | 69 +- tools/perf/util/event.h | 3 + tools/perf/util/hist.c | 52 +- tools/perf/util/hist.h | 5 + tools/perf/util/session.c | 60 +- tools/perf/util/session.h | 4 + tools/perf/util/sort.c | 3 + tools/perf/util/sort.h | 3 + tools/perf/util/symbol.h | 9 +- tools/perf/util/util.c | 4 + 27 files changed, 1304 insertions(+), 26 deletions(-) create mode 100644 arch/x86/kernel/cpu/perf_event_intel_core_misc.c create mode 100644 arch/x86/kernel/cpu/perf_event_intel_core_misc.h
Signature · 1 line
1.8.3.1