Skip to content

Intel core misc PMUs support

[email protected] lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 23 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9perf/x86: Add Intel core misc PMUs supportarch/x86/kernel/cpu/Makefile arch/x86/kernel/cpu/perf_event_intel_core_misc.c arch/x86/kernel/cpu/perf_event_intel_core_misc.h+987 -00 replies
2/9perf/x86: core_misc PMU disable and enable supportarch/x86/include/asm/perf_event.h arch/x86/kernel/cpu/perf_event.h arch/x86/kernel/cpu/perf_event_intel.c +1 more+57 -010 replies
3/9perf/x86: Add is_hardware_eventinclude/linux/perf_event.h kernel/events/core.c+9 -44 replies
4/9perf/x86: special case per-cpu core misc PMU eventsarch/x86/kernel/cpu/perf_event_intel_core_misc.c include/linux/perf_event.h include/linux/sched.h +2 more+26 -35 replies
5/9perf,tools: open event with it's own cpus and threadstools/perf/builtin-record.c+1 -10 replies
6/9perf,tools: Dump per-sample freq in report -Dtools/perf/util/session.c tools/perf/util/session.h+39 -50 replies
7/9perf,tools: save APERF/MPERF/TSC in struct perf_sampletools/perf/util/event.h tools/perf/util/session.c+23 -00 replies
8/9perf,tools: caculate and save tsc/avg/bzy freq in he_stattools/perf/builtin-annotate.c tools/perf/builtin-diff.c tools/perf/tests/hists_link.c +4 more+61 -103 replies
9/9perf,tools: Show freq in perf report --stdiotools/perf/Documentation/perf-report.txt tools/perf/builtin-report.c tools/perf/perf.h +6 more+105 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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       [.] f2

2. 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