Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754010AbbGQDsd (ORCPT ); Thu, 16 Jul 2015 23:48:33 -0400 Received: from mga11.intel.com ([192.55.52.93]:62184 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752494AbbGQDsb (ORCPT ); Thu, 16 Jul 2015 23:48:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,492,1432623600"; d="scan'208";a="607841820" 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 Subject: [PATCH 0/9] Intel core misc PMUs support Date: Thu, 16 Jul 2015 16:33:42 -0400 Message-Id: <1437078831-10152-1-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5310 Lines: 122 From: Kan Liang 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/