lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 16 Jul 2015 16:33:42 -0400
From:	kan.liang@...el.com
To:	a.p.zijlstra@...llo.nl
Cc:	mingo@...hat.com, acme@...nel.org, eranian@...gle.com,
	ak@...ux.intel.com, mark.rutland@....com, adrian.hunter@...el.com,
	dsahern@...il.com, jolsa@...nel.org, namhyung@...nel.org,
	linux-kernel@...r.kernel.org, Kan Liang <kan.liang@...el.com>
Subject: [PATCH 0/9] Intel core misc PMUs support

From: Kan Liang <kan.liang@...el.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ