From: kan.liang@intel.com
To: a.p.zijlstra@chello.nl
Cc: mingo@redhat.com, acme@kernel.org, eranian@google.com,
ak@linux.intel.com, mark.rutland@arm.com,
adrian.hunter@intel.com, dsahern@gmail.com, jolsa@kernel.org,
namhyung@kernel.org, linux-kernel@vger.kernel.org,
Kan Liang <kan.liang@intel.com>
Subject: [PATCH 0/9] Intel core misc PMUs support
Date: Thu, 16 Jul 2015 16:33:42 -0400 [thread overview]
Message-ID: <1437078831-10152-1-git-send-email-kan.liang@intel.com> (raw)
From: Kan Liang <kan.liang@intel.com>
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
--
1.8.3.1
next reply other threads:[~2015-07-17 3:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 20:33 kan.liang [this message]
2015-07-16 20:33 ` [PATCH 1/9] perf/x86: Add " kan.liang
2015-07-16 20:33 ` [PATCH 2/9] perf/x86: core_misc PMU disable and enable support kan.liang
2015-07-17 12:11 ` Mark Rutland
2015-07-17 13:46 ` Peter Zijlstra
2015-07-17 13:51 ` Peter Zijlstra
2015-07-17 15:35 ` Liang, Kan
2015-07-17 17:01 ` Andy Lutomirski
2015-07-17 17:52 ` Liang, Kan
2015-07-17 17:58 ` Andy Lutomirski
2015-07-17 18:15 ` Liang, Kan
2015-07-17 18:56 ` Andy Lutomirski
2015-07-17 21:11 ` Peter Zijlstra
2015-07-16 20:33 ` [PATCH 3/9] perf/x86: Add is_hardware_event kan.liang
2015-07-17 10:48 ` Mark Rutland
2015-07-17 15:03 ` Liang, Kan
2015-07-17 15:47 ` Mark Rutland
2015-07-17 16:11 ` Mark Rutland
2015-07-16 20:33 ` [PATCH 4/9] perf/x86: special case per-cpu core misc PMU events kan.liang
2015-07-17 12:21 ` Mark Rutland
2015-07-17 12:55 ` Peter Zijlstra
2015-07-17 18:11 ` Stephane Eranian
2015-07-17 20:17 ` Andi Kleen
2015-07-20 16:12 ` Mark Rutland
2015-07-16 20:33 ` [PATCH 5/9] perf,tools: open event with it's own cpus and threads kan.liang
2015-07-16 20:33 ` [PATCH 6/9] perf,tools: Dump per-sample freq in report -D kan.liang
2015-07-16 20:33 ` [PATCH 7/9] perf,tools: save APERF/MPERF/TSC in struct perf_sample kan.liang
2015-07-16 20:33 ` [PATCH 8/9] perf,tools: caculate and save tsc/avg/bzy freq in he_stat kan.liang
2015-07-17 20:25 ` Andi Kleen
2015-07-17 20:57 ` Liang, Kan
2015-07-17 21:27 ` Andi Kleen
2015-07-16 20:33 ` [PATCH 9/9] perf,tools: Show freq in perf report --stdio kan.liang
2015-07-17 11:39 ` [PATCH 0/9] Intel core misc PMUs support Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437078831-10152-1-git-send-email-kan.liang@intel.com \
--to=kan.liang@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome