Commit graph

633410 commits

Author SHA1 Message Date
Stefano Sanfilippo 0284fecd13 perf jit: Add unwinding support
This record is intended to provide unwinding information in the
eh_frame format. This is required to unwind JITed code which
does not maintain the frame pointer register during function calls.

The eh_frame unwinding information can be emitted by V8 / Chromium
when the --perf_prof_unwinding_info is passed.

A record of type jr_code_unwinding_info comes before the jr_code_load
it referred to and contains both the .eh_frame and .eh_frame_hdr.

The fields in the header have the following meaning:

  * unwinding_size: size of the eh_frame and eh_frame_hdr, necessary
    for distinguishing the content from the padding.

  * eh_frame_hdr_size: as the name says.

  * mapped_size: size of the payload that was in memory at runtime.
    typically unwinding_size if the .eh_frame_hdr and .eh_frame were
    mapped, or 0 if they weren't. It should always be the former case,
    since the .eh_frame is guaranteed to be mapped in memory. However,
    certain JITs might want to inject an .eh_frame_hdr with an empty LUT
    to trigger fp-based unwinding fallback in libunwind. The only part
    of the .eh_frame_hdr that libunwind reads from remote memory is the
    LUT, and since there is none, mapping the unwinding info in memory
    is not necessary, and 0 in this field signifies that it wasn't.
    This practical hack allows to save bytes in code memory for those
    JIT compilers that might or might not maintain a valid frame pointer.

The payload that follows is assumed to contain first the .eh_frame and
then the .eh_header_hdr, with no padding between the two.

Signed-off-by: Stefano Sanfilippo <ssanfilippo@chromium.org>
Signed-off-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-7-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:39 -03:00
Stefano Sanfilippo eac05af2bf perf jit: Do not assume pgoff is zero
When calculating .eh_frame_hdr base and LUT offsets do not always assume
that pgoff is zero.

The assumption is false for DSOs built from the jitdump by perf inject,
because the ELF header did not exist in memory at sampling time.

Signed-off-by: Stefano Sanfilippo <ssanfilippo@chromium.org>
Signed-off-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-6-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:39 -03:00
Stefano Sanfilippo 7354ec7a86 perf jit: Make perf skip unknown records
The behavior before this commit was to skip the remaining portion of the
jitdump in case an unknown record was found, including those records
that perf could handle.

With this change, parsing a record with an unknown id will cause a
warning to be emitted, the record will be skipped and parsing will
resume from the next (valid) one.

The patch aims at making perf more future proof, by extracting as much
information as possible from jitdumps.

Signed-off-by: Stefano Sanfilippo <ssanfilippo@chromium.org>
Signed-off-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-5-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:38 -03:00
Stephane Eranian 13b9012ab4 perf jit: Remove unecessary padding in jitdump file
This patch removes all the string padding generated in the jitdump file.
They are not necessary and were adding unnecessary complexity. Modern
processors can handle unaligned accesses quite well. The perf.data/
jitdump file are always post-processed, no need to add extra complexity
for no real gain.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-4-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:38 -03:00
Maciej Debski 621cb4e783 perf jit: Enable jitdump support without dwarf
This patch modifies the build dependencies on the jitdump support in
perf. As it stands jitdump was wrongfully made dependent 100% on using
DWARF. However, the dwarf dependency, only exist if generating the
source line table in genelf_debug.c. The rest of the support does not
need DWARF.

This patch removes the dependency on DWARF for the entire jitdump
support. It keeps it only for the genelf_debug.c support.

Signed-off-by: Maciej Debski <maciejd@google.com>
Reviewed-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-3-git-send-email-eranian@google.com
Fixes: e12b202f8f ("perf jitdump: Build only on supported archs")
[ Make it build only if NO_LIBELF isn't defined, as jitdump.o will only be built in that case ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:37 -03:00
Stephane Eranian cdd75e3b0d perf jit: Improve error messages from JVMTI
This patch improves the usefulness of error messages generated by the
JVMTI interfac.e This can help identify the root cause of a problem by
printing the actual error code. The patch adds a new helper function
called print_error().

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nilay Vaish <nilayvaish@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1476356383-30100-2-git-send-email-eranian@google.com
[ Handle failure to convert numeric error to a string in print_error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:37 -03:00
Arnaldo Carvalho de Melo 5fef5f3f09 perf jit: Add NT_GNU_BUILD_ID definition for older distros
Such as CentOS5, where such define is not present in elf.h.

This file, genelf.c, wasn't being built for several systems, because
it mistakenly was conditional on some DWARF features, now that it
is just needing libelf, after "perf jit: Enable jitdump support without
dwarf" it fails.

So, as preparation for "perf jit: Enable jitdump support without dwarf",
conditionally define it, if not available.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Maciej Debski <maciejd@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-k09qay1cmr0l3fzprmztzy3o@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:36 -03:00
Arnaldo Carvalho de Melo ef2c3e76d9 perf jit: Avoid returning garbage for a ret variable
When the loop body isn't executed at all, then the 'ret' local variable,
that is uninitialized will be used as the return value.

This triggers this error on Alpine Linux:

    CC	   /tmp/build/perf/util/demangle-java.o
    CC	   /tmp/build/perf/util/demangle-rust.o
    CC       /tmp/build/perf/util/jitdump.o
    CC       /tmp/build/perf/util/genelf.o
  util/jitdump.c: In function 'jit_process':
  util/jitdump.c:622:3: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     fprintf(stderr, "injected: %s (%d)\n", path, ret);
     ^
  util/jitdump.c:584:6: note: 'ret' was declared here
    int ret;
        ^
    FLEX     /tmp/build/perf/util/parse-events-flex.c

  / $ gcc -v
  Using built-in specs.
  COLLECT_GCC=gcc
  COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-alpine-linux-musl/5.3.0/lto-wrapper
  Target: x86_64-alpine-linux-musl
  Configured with: /home/buildozer/aports/main/gcc/src/gcc-5.3.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
  +--build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl --target=x86_64-alpine-linux-musl --with-pkgversion='Alpine 5.3.0' --enable-checking=release
  +--disable-fixed-point --disable-libstdcxx-pch --disable-multilib --disable-nls --disable-werror --disable-symvers --enable-__cxa_atexit --enable-esp
  +--enable-cloog-backend --enable-languages=c,c++,objc,java,fortran,ada --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-shared
  +--enable-threads --enable-tls --with-system-zlib
  Thread model: posix
  gcc version 5.3.0 (Alpine 5.3.0)

But this so far got under the radar, not causing any build problem, till the
"perf jit: enable jitdump support without dwarf" gets applied, when the above
problem takes place, some combination of inlining or whatever, the problem
is real, so fix it by initializing the variable to zero.

Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Maciej Debski <maciejd@google.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lkml.kernel.org/r/20161013200437.GA12815@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:36 -03:00
Andi Kleen ac12f6764c perf tools: Implement branch_type event parameter
It can be useful to specify branch type state per event, for example if
we want to collect both software trace points and last branch PMU events
in a single collection. Currently this doesn't work because the software
trace point errors out with -b.

There was already a branch-type parameter to configure branch sample
types per event in the parser, but it was stubbed out. This patch
implements the necessary plumbing to actually enable it.

Now:

  $ perf record -e sched:sched_switch,cpu/cpu-cycles,branch_type=any/ ...

works.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1476306127-19721-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:35 -03:00
Andi Kleen 84ee74affc perf record: Improve documentation of event parameters
- Some editing (params -> parameters)
- Point to the now more complete list of parameters in the perf list
manpage.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/1476381433-22959-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:35 -03:00
Jiri Olsa 0c2aff4c78 perf header: Display feature name on write failure
Display name of feature instead of just the number
during recording data.

Before:
  failed to write feature 13

Now:
  failed to write feature HEADER_CPU_TOPOLOGY

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-k9d9trozi5kkx737cy8n5xh5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:34 -03:00
Jiri Olsa aabae16575 perf header: Display missing features
Display missing features in header info, like:

  $ perf report --header-only
  # ========
  # captured on: Mon Oct 10 09:39:47 2016
  ...
  # missing features: HEADER_TRACING_DATA HEADER_CPU_TOPOLOGY ...

To help in diagnosing problems.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-bh5gp84gobdmyl345dcp64se@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:34 -03:00
Jiri Olsa f45f56151a perf report: Move captured info to generic header info
It's not displayed in TUI now, putting it into generic part.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-5fk88kejqgi50ye7xdkhiloz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:33 -03:00
Jiri Olsa 02bc11de56 tools lib: Add for_each_clear_bit macro
Adding for_each_clear_bit macro plus all its the necessary backbone
functions. Taken from related kernel code. It will be used in following
patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-cayv2zbqi0nlmg5sjjxs1775@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:33 -03:00
Jiri Olsa fe316723a8 tools lib traceevent: Add version for traceevent shared object
Adding version support for libtraceevent.so object.

Using the existing EVENT_PARSE_VERSION variable to construct
the .so object version string, which now consists of:

  $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)

Looks like it was created for this purpose anyway.

The build will now produce following traeceevent libraries:

  $ ll libtraceevent*
  libtraceevent.a
  libtraceevent.so -> libtraceevent.so.1.1.0
  libtraceevent.so.1 -> libtraceevent.so.1.1.0
  libtraceevent.so.1.1.0

Also the install target will carry them:

  $ make DESTDIR=/tmp/krava prefix=/usr install
  INSTALL  trace_plugins
  INSTALL  libtraceevent.a
  INSTALL  libtraceevent.so.1.1.0

  $ find /tmp/krava/ | xargs ls -l
  ...
  /tmp/krava/usr/lib64:
  total 572
  libtraceevent.a
  libtraceevent.so -> libtraceevent.so.1.1.0
  libtraceevent.so.1 -> libtraceevent.so.1.1.0
  libtraceevent.so.1.1.0
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-v64z62fh0dwt0ueie5usrnac@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:32 -03:00
Jiri Olsa 39944a768a tools lib traceevent: Rename LIB_FILE to LIB_TARGET
To ease up following patch.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-zpv5gd8y7clwrhh6dq03ucd5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:32 -03:00
Jiri Olsa c121bdbb87 tools lib traceevent: Add do_install_mkdir Makefile function
Decompose the do_install function to ease up
the following patch a little.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-zzs19yx8seyors532vuer37w@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:31 -03:00
Jiri Olsa 722a498407 tools lib traceevent: Add install_headers target
Adding install_headers target to install all headers
under 'include/traceevent' path, like:

  $ make DESTDIR=/tmp/krava prefix=/usr install_headers
  $ find /tmp/krava/ -type f
  /tmp/krava/usr/include/traceevent/kbuffer.h
  /tmp/krava/usr/include/traceevent/event-utils.h
  /tmp/krava/usr/include/traceevent/event-parse.h

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-if70lj3zhdc3csdqm5webjvc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:31 -03:00
Arnaldo Carvalho de Melo b4974b4055 perf tools: Sync copy of x86's syscall table
To get up to the recent compat pread/pwrite changes, that albeit not
being used by 'perf trace' due to some raw_syscalls tracepoint
limitations, trigger this warning when building perf:

  Warning: x86_64's syscall_64.tbl differs from kernel

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ilgqhxd9ubkg5f66bx0bht2t@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:30 -03:00
Andi Kleen 224e2c977b perf script: Support insn and insnlen
When looking at Intel PT traces with perf script it is useful to have
some indication of the instruction. Dump the instruction bytes and
instruction length, which can be used for simple pattern analysis in
scripts.

% perf record -e intel_pt// foo
% perf script --itrace=i0ns -F ip,insn,insnlen
 ffffffff8101232f ilen: 5 insn: 0f 1f 44 00 00
 ffffffff81012334 ilen: 1 insn: 5b
 ffffffff81012335 ilen: 1 insn: 5d
 ffffffff81012336 ilen: 1 insn: c3
 ffffffff810123e3 ilen: 1 insn: 5b
 ffffffff810123e4 ilen: 2 insn: 41 5c
 ffffffff810123e6 ilen: 1 insn: 5d
 ffffffff810123e7 ilen: 1 insn: c3
 ffffffff810124a6 ilen: 2 insn: 31 c0
 ffffffff810124a8 ilen: 9 insn: 41 83 bc 24 a8 01 00 00 01
 ffffffff810124b1 ilen: 2 insn: 75 87
...

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: http://lkml.kernel.org/r/1475847747-30994-4-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 11:07:30 -03:00
Andi Kleen faaa87680b perf intel-pt/bts: Report instruction bytes and length in sample
Change Intel PT and BTS to pass up the length and the instruction
bytes of the decoded or sampled instruction in the perf sample.

The decoder already knows this information, we just need to pass it
up. Since it is only a couple of movs it is not very expensive.

Handle instruction cache too. Make sure ilen is always initialized.

Used in the next patch.

[Adrian: re-base on top (and adjust for) instruction buffer size tidy-up]
[Adrian: add BTS support and adjust commit message accordingly]

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Link: http://lkml.kernel.org/r/1475847747-30994-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 10:31:32 -03:00
Adrian Hunter 32f98aab75 perf intel-pt/bts: Tidy instruction buffer size usage
Tidy instruction buffer size usage in preparation for copying the
instruction bytes onto samples.

The instruction buffer is presently used for debugging, so rename its
size macro from INTEL_PT_INSN_DBG_BUF_SZ to INTEL_PT_INSN_BUF_SZ, and
use it everywhere.

Note that the maximum instruction size is 15 which is a less efficient size
to copy than 16, which is why a separate buffer size is used.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1475847747-30994-2-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-24 10:31:32 -03:00
Ingo Molnar e9c848928a - The 'perf c2c' tool provides means for Shared Data C2C/HITM analysis.
It allows you to track down cacheline contention. The tool is based
   on x86's load latency and precise store facility events provided by
   Intel CPUs.
 
   It was tested by Joe Mario and has proven to be useful, finding some
   cacheline contentions. Joe also wrote a blog about c2c tool with
   examples:
 
     https://joemario.github.io/blog/2016/09/01/c2c-blog/
 
   Excerpt of the content on this site:
 
   ---
     At a high level, “perf c2c” will show you:
 
     * The cachelines where false sharing was detected.
     * The readers and writers to those cachelines, and the offsets where those accesses occurred.
     * The pid, tid, instruction addr, function name, binary object name for those readers and writers.
     * The source file and line number for each reader and writer.
     * The average load latency for the loads to those cachelines.
     * Which numa nodes the samples a cacheline came from and which CPUs were involved.
 
     Using perf c2c is similar to using the Linux perf tool today.
     First collect data with “perf c2c record” Then generate a report output with “perf c2c report”
   ---
 
   There one finds extensive details on using the tool, with tips on
   reducing the volume of samples while still capturing enough to do
   its job. (Dick Fowles, Joe Mario, Don Zickus, Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJYChlxAAoJENZQFvNTUqpAZ5wQAKKCA9NbcMUGcuoQK7F8KiK1
 A+x+gAL2yHGDkr3mBCxaVUhYN3iB7o2tVzyZD3JcL7cXDMGmKVz0MjOZWe2qErL7
 2xpCBOOtEFwPmVn5kVtotPac6JVUAK/HmWD5vac7+oJ2+jQfUURcR2HeKB7JYmjs
 0VuSMR+6QeTCAGBaWfuNTQaNn8uBE5VMPON6tWbvke5ZVbgr5s2GLfr6ElQp9IHI
 vEUQ1VzjbEVNLGO/sRLH173Ubf+TOQE2mU9p3b72x+NlnN07C7GHAlnk+a1ZCzLW
 K2FviFDdpl38KeUzt2492IF/Q66l0GI/eQ4FI20Kzw+Z5VoGfyDz491Q3kGRPOZd
 bogAduP2ZS1mb0aV7riBbKZGOTg20tCzKkb7PqQmJ74qn84igSH9xrOW0XvcduKS
 seR2BmD2nofSIqv++SQ4Kx+0Oy7Y+LyGdNGb4nAOYLYnIDLXwnuWW3IC97HBcGBy
 6p9FLF7cUH5YXD7Yva59qgOvI/Ij8BIS6SgTqXEUHw/Y1kPpVBEM6x8wIw74w4ZR
 Lg9KCtKrOVkV5BicqM+j5Aro4IGIsyksbQ7CRPyuTRSvzlmkL2Y5hRJ0ybyWqw/V
 qeE+wNVWI7p0/QF1f5wIXxwvtMFac++XDYPci6cxBS7QwbzRF+RcIJb59EgqeFx4
 65xyxgNuHvKF2AFY1coi
 =h0F1
 -----END PGP SIGNATURE-----

Merge tag 'perf-c2c-for-mingo-20161021' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull new 'perf c2c' tool from Arnaldo Carvalho de Melo:

- The 'perf c2c' tool provides means for Shared Data C2C/HITM analysis.

  It allows you to track down cacheline contention. The tool is based
  on x86's load latency and precise store facility events provided by
  Intel CPUs.

  It was tested by Joe Mario and has proven to be useful, finding some
  cacheline contentions. Joe also wrote a blog about c2c tool with
  examples:

    https://joemario.github.io/blog/2016/09/01/c2c-blog/

  Excerpt of the content on this site:

  ---
    At a high level, “perf c2c” will show you:

    * The cachelines where false sharing was detected.
    * The readers and writers to those cachelines, and the offsets where those accesses occurred.
    * The pid, tid, instruction addr, function name, binary object name for those readers and writers.
    * The source file and line number for each reader and writer.
    * The average load latency for the loads to those cachelines.
    * Which numa nodes the samples a cacheline came from and which CPUs were involved.

    Using perf c2c is similar to using the Linux perf tool today.
    First collect data with “perf c2c record” Then generate a report output with “perf c2c report”
  ---

  There one finds extensive details on using the tool, with tips on
  reducing the volume of samples while still capturing enough to do
  its job. (Dick Fowles, Joe Mario, Don Zickus, Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-10-22 10:22:05 +02:00
Jiri Olsa af09b2d35e perf c2c report: Add --show-all option
Normally we limit the main list to contain only entries with HITM %
value > 0.0005, but it might be useful to display all captured entries.
Adding --show-all option for that.

Requested-and-Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-nokgjdwikbegec5jzj4mxhqc@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:32:02 -03:00
Jiri Olsa 18f278d2dd perf c2c report: Add --no-source option
Add a possibility to disable source line column with new --no-source
option. It source line data could take lot of time to retrieve, so it
could be a performance burden for big data.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-8p6s2727fq8nbsm3it5gix3p@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:32:01 -03:00
Jiri Olsa 465f27a3b2 perf c2c: Add man page and credits
Add man page for c2c command and credits to builtin-c2c.c file.

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-twbp391v8v9f5idp584hlfov@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:32:01 -03:00
Jiri Olsa 9a406eb610 perf c2c report: Add help windows
Adding help windows to display key/action mappings
for both browsers.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-zni4apopx6a9eyxsosm1ebh1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:32:00 -03:00
Jiri Olsa 1a56a42534 perf c2c report: Iterate node display in browser
Adding TUI support to switch between Node entry versions
in real time with 'n' key.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-xqbw4h4dxig54wff7fd14lao@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:32:00 -03:00
Jiri Olsa 590b6a3ac5 perf c2c report: Add support to manage symbol name length
The width of symbol and source line entries could get really long
and not convenient to display. Adding support to display only
patrt of such strings and possibility to switch to full length
by uing --full-symbols option or 's' key in TUI browser.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-yxf5hfteyfaoi8xrgczqtyha@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:59 -03:00
Jiri Olsa bb342daed8 perf c2c report: Add cacheline index entry
It's convenient to have an index for each cacheline to help discussions
about results over the phone.

Add new 'Index' and 'Num' fields in main and single cacheline tables.

$ perf c2c report
  =================================================
             Shared Data Cache Line Table
  =================================================
  #
  #                              Total      Lcl  ----- LLC Load Hitm -----
  # Index           Cacheline  records     Hitm    Total      Lcl      Rmt  ...
  # .....  ..................  .......  .......  .......  .......  .......
  #
        0  0xffff880036233b40        1   11.11%        1        1        0
        1  0xffff88009ccb2900        1   11.11%        1        1        0
        2  0xffff8800b5b3bc40        7   11.11%        1        1        0
  ...

  =================================================
        Shared Cache Line Distribution Pareto
  =================================================
  #
  #        ----- HITM -----  -- Store Refs --        Data address
  #   Num      Rmt      Lcl   L1 Hit  L1 Miss              Offset      Pid  ...
  # .....  .......  .......  .......  .......  ..................  .......
  #
    -------------------------------------------------------------
        0        0        1        0        0  0xffff880036233b40
    -------------------------------------------------------------
             0.00%  100.00%    0.00%    0.00%                0x30        0

    -------------------------------------------------------------
        1        0        1        0        0  0xffff88009ccb2900
    -------------------------------------------------------------
             0.00%  100.00%    0.00%    0.00%                0x28      549
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-4dhfagaz57tvrfjbg8nd2h4u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:59 -03:00
Jiri Olsa 25aa84e32d perf c2c report: Recalc width of global sort entries
Using resort callbacks to compute the columns' width.

Computing only the global ones, c2c entries have fixed width only.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-zyayvq2u3dzyf3y7i9jza0lw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:58 -03:00
Jiri Olsa fc9c630e8e perf c2c report: Allow to set cacheline sort fields
Allowing user to configure the way the single cacheline
data are sorted after being sorted by offset.

Adding 'c' option to specify sorting fields for single cacheline:

    -c, --coalesce <coalesce fields>
                          coalesce fields: pid,tid,iaddr,dso

It's allowed to use following combination of fields:
  pid   - process pid
  tid   - process tid
  iaddr - code address
  dso   - shared object

Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-aka8z31umxoq2gqr5mjd81zr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:58 -03:00
Jiri Olsa 55b9577672 perf c2c report: Add support to choose local HITMs
Currently we sort and limit displayed data based on the remote HITMs
count. Adding support to switch to local HITMs via --display option:

        --display ...     lcl,rmt

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-inykbom2f19difvsu1e18avr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:57 -03:00
Jiri Olsa 9857b7173c perf c2c report: Limit the cachelines table entries
Add a limit for entries number of the cachelines table entries. By
default now it's the 0.0005% minimum of remote HITMs.

Also display only cachelines with remote hitm or store data.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-inykbom2f19difvsu1e18avr@git.kernel.org
[ Disabled for now ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:57 -03:00
Jiri Olsa dd805768f7 perf c2c report: Allow to report callchains
Add --call-graph option to properly setup callchain code. Adding default
settings to display callchains whenever they are stored in the
perf.data.

Committer Notes:

Testing it:

  [root@jouet ~]# perf c2c record -a -g sleep 5
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 5.331 MB perf.data (4263 samples) ]
  [root@jouet ~]# perf evlist -v
  cpu/mem-loads,ldlat=30/P: type: 4, size: 112, config: 0x1cd, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|ID|CPU|PERIOD|DATA_SRC|WEIGHT, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, mmap_data: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, { bp_addr, config1 }: 0x1f
  cpu/mem-stores/P: type: 4, size: 112, config: 0x82d0, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|ID|CPU|PERIOD|DATA_SRC|WEIGHT, read_format: ID, disabled: 1, inherit: 1, freq: 1, precise_ip: 3, sample_id_all: 1
  [root@jouet ~]# perf c2c report --stats
  =================================================
              Trace Event Information
  =================================================
    Total records                     :       4263
    Locked Load/Store Operations      :        220
    Load Operations                   :       2130
    Loads - uncacheable               :          1
    Loads - IO                        :          7
    Loads - Miss                      :         86
    Loads - no mapping                :          5
    Load Fill Buffer Hit              :        609
    Load L1D hit                      :        612
  =================================================
              Trace Event Information
  =================================================
    Total records                     :       4263
    Locked Load/Store Operations      :        220
    Load Operations                   :       2130
    Loads - uncacheable               :          1
    Loads - IO                        :          7
    Loads - Miss                      :         86
    Loads - no mapping                :          5
    Load Fill Buffer Hit              :        609
    Load L1D hit                      :        612
    Load L2D hit                      :         27
    Load LLC hit                      :        607
    Load Local HITM                   :         15
    Load Remote HITM                  :          0
    Load Remote HIT                   :          0
    Load Local DRAM                   :        176
    Load Remote DRAM                  :          0
    Load MESI State Exclusive         :        176
    Load MESI State Shared            :          0
    Load LLC Misses                   :        176
    LLC Misses to Local DRAM          :      100.0%
    LLC Misses to Remote DRAM         :        0.0%
    LLC Misses to Remote cache (HIT)  :        0.0%
    LLC Misses to Remote cache (HITM) :        0.0%
    Store Operations                  :       2133
    Store - uncacheable               :          0
    Store - no mapping                :          1
    Store L1D Hit                     :       1967
    Store L1D Miss                    :        165
    No Page Map Rejects               :        145
    Unable to parse data source       :          0

  =================================================
      Global Shared Cache Line Event Information
  =================================================
    Total Shared Cache Lines          :         15
    Load HITs on shared lines         :         26
    Fill Buffer Hits on shared lines  :          7
    L1D hits on shared lines          :          3
    L2D hits on shared lines          :          0
    LLC hits on shared lines          :         16
    Locked Access on shared lines     :          2
    Store HITs on shared lines        :          8
    Store L1D hits on shared lines    :          7
    Total Merged records              :         23

  =================================================
                   c2c details
  =================================================
    Events                            : cpu/mem-loads,ldlat=30/P
                                      : cpu/mem-stores/P
  [root@jouet ~]#

  [root@jouet ~]# perf c2c report
Shared Data Cache Line Table (2378 entries)
                        Total           --- LLC Load Hitm --  -- Store Reference -  - Load Dram -   LLC      Total  - Core Load Hit -
           Cacheline  records    %hitm  Total   Lcl      Rmt  Total  L1Hit  L1Miss  Lcl  Rmt        Ld Miss  Loads   FB       L1   L2
- 0xffff880024380c00       10    0.00%      0     0        0      6      6       0    0    0        0            4    1        3    0
   - 0.13% _raw_spin_lock_irqsave
      - 0.07% ep_poll
           sys_epoll_wait
           do_syscall_64
           return_from_SYSCALL_64
         + 0x103573
      - 0.05% ep_poll_callback
           __wake_up_common
         - __wake_up_sync_key
            - 0.02% pipe_read
                 __vfs_read
                 vfs_read
                 sys_read
                 do_syscall_64
                 return_from_SYSCALL_64
                 0xfdad
            + 0.02% sock_def_readable
      + 0.02% ep_scan_ready_list.constprop.12
   + 0.00% mutex_lock
   + 0.00% __wake_up_common
+ 0xffff880024380c40        1    0.00%      0     0        0      1      1       0    0    0        0            0    0        0    0
+ 0xffff880024380c80        1    0.00%      0     0        0      0      0       0    0    0        0            1    0        0    0
- 0xffff8800243e9f00        1    0.00%      0     0        0      1      1       0    0    0        0            0    0        0    0
     enqueue_entity
     enqueue_task_fair
     activate_task
     ttwu_do_activate
     try_to_wake_up
     wake_up_process
     hrtimer_wakeup
     __hrtimer_run_queues
     hrtimer_interrupt
     local_apic_timer_interrupt
     smp_apic_timer_interrupt
     apic_timer_interrupt
     cpuidle_enter
     call_cpuidle
help

 -------------

And when presing 'd' to see the cacheline details:

Cacheline 0xffff880024380c00
  ----- HITM -----  -- Store Refs --                                       --------- cycles -----  cpu
      Rmt      Lcl   L1 Hit  L1 Miss    Off     Pid                   Tid  rmt hitm lcl hitm load  cnt                      Symbol
-   0.00%    0.00%  100.00%    0.00%    0x0    1473  1474:Chrome_ChildIOT         0        0   41    2  [k] _raw_spin_lock_irqsave [kernel]
   - _raw_spin_lock_irqsave
      - 51.52% ep_poll
           sys_epoll_wait
           do_syscall_64
           return_from_SYSCALL_64
         - 0x103573
              47.19% 0
              4.33% 0xc30bd
      - 35.93% ep_poll_callback
           __wake_up_common
         - __wake_up_sync_key
            - 18.20% pipe_read
                 __vfs_read
                 vfs_read
                 sys_read
                 do_syscall_64
                 return_from_SYSCALL_64
                 0xfdad
            - 17.73% sock_def_readable
                 unix_stream_sendmsg
                 sock_sendmsg
                 ___sys_sendmsg
                 __sys_sendmsg
                 sys_sendmsg
                 do_syscall_64
                 return_from_SYSCALL_64
                 __GI___libc_sendmsg
                 0x12c036af1fc0
                 0x16a4050
                 0x894928ec83485354
      + 12.45% ep_scan_ready_list.constprop.12
+   0.00%    0.00%    0.00%    0.00%    0x8    1473  1474:Chrome_ChildIOT         0        0  102    1  [k] mutex_lock             [kernel]
+   0.00%    0.00%    0.00%    0.00%   0x38    1473  1473:chrome                  0        0   88    1  [k] __wake_up_common       [kernel]

help

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-inykbom2f19difvsu1e18avr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:56 -03:00
Jiri Olsa 2709b97dc2 perf c2c report: Add c2c related stats stdio output
Display c2c related configuration options/setup.
So far it's output of monitored events:

  $ perf c2c report --stats
  ...

  =================================================
                   c2c details
  =================================================
    Events                            : cpu/mem-loads,ldlat=50/pp
                                      : cpu/mem-stores/pp

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-ypz84f3a9fumyttrxurm458z@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:56 -03:00
Jiri Olsa 7ef2efaab4 perf c2c report: Add shared cachelines stats stdio output
Display global shared cachelines related stats table as part of the
stdio output or when --stats option is speicified:

  $ perf c2c report --stats
  ...
  =================================================
      Global Shared Cache Line Event Information
  =================================================
    Total Shared Cache Lines          :       1384
    Load HITs on shared lines         :       5995
    Fill Buffer Hits on shared lines  :       1726
    L1D hits on shared lines          :       1943
    L2D hits on shared lines          :          0
    LLC hits on shared lines          :       1360
    Locked Access on shared lines     :       1993
    Store HITs on shared lines        :       1504
    Store L1D hits on shared lines    :       1446
    Total Merged records              :       3527

Original-patch-by: Dick Fowles <rfowles@redhat.com>
Original-patch-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-p0gty8ctbdzisrniwqxhqmhq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:55 -03:00
Jiri Olsa 74c63a25f2 perf c2c report: Add global stats stdio output
Display global stats table as part of the stdio output
or when --stats option is speicified:

  $ perf c2c report --stats
  =================================================
              Trace Event Information
  =================================================
    Total records                     :      41237
    Locked Load/Store Operations      :       4075
    Load Operations                   :      20526
    Loads - uncacheable               :          0
    Loads - IO                        :          0
    Loads - Miss                      :        552
    Loads - no mapping                :         31
    Load Fill Buffer Hit              :       7333
    Load L1D hit                      :       6398
    Load L2D hit                      :        144
    Load LLC hit                      :       4889
    Load Local HITM                   :       1185
    Load Remote HITM                  :        838
    Load Remote HIT                   :         52
    Load Local DRAM                   :        183
    Load Remote DRAM                  :        106
    Load MESI State Exclusive         :        289
    Load MESI State Shared            :          0
    Load LLC Misses                   :       1179
    LLC Misses to Local DRAM          :       15.5%
    LLC Misses to Remote DRAM         :        9.0%
    LLC Misses to Remote cache (HIT)  :        4.4%
    LLC Misses to Remote cache (HITM) :       71.1%
    Store Operations                  :      20711
    Store - uncacheable               :          0
    Store - no mapping                :          1
    Store L1D Hit                     :      20158
    Store L1D Miss                    :        552
    No Page Map Rejects               :          7
    Unable to parse data source       :          0

Original-patch-by: Dick Fowles <rfowles@redhat.com>
Original-patch-by: Don Zickus <dzickus@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-qkyvao3qsrnwazf0w1jvsh7z@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:55 -03:00
Jiri Olsa f1c5fd4d0b perf c2c report: Add TUI cacheline browser
Adding simple TUI cacheline browser. It triggers when you press 'd' in
the main browser on the specific cacheline.

It allows to navigate through cacheline's offsets and display callchains
(implemented in following patches).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-fovjwgyusv3rz5qxk3hnahtl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:31:55 -03:00
Jiri Olsa 5a1a99cd2e perf c2c report: Add main TUI browser
Add the main cachelines TUI browser. It allows to navigate through
cachelines and display their details and callchains (implemented in the
following patches).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Kim Phillips <kim.phillips@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-pk632k4h1uwc5t0lqc7k61zg@git.kernel.org
Link: http://lkml.kernel.org/r/20161021001706.GB23970@krava
[ Handle file with no entries, fixing segfault reported by Kim Phillips ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-21 10:30:03 -03:00
Jiri Olsa 2d388bd0c9 perf c2c report: Add stdio output support
Adding the --stdio option output support. The output
tables are dumped directly to the stdio.

$ perf c2c report
  =================================================
             Shared Data Cache Line Table
  =================================================
  #
  #                       Total           ----- LLC Load Hitm -----  ---- Store Reference ----  --- Load Dram ----      LLC    Total  ----- Core Load Hit -----  -- LLC Load Hit --
  #          Cacheline  records    %hitm    Total      Lcl      Rmt    Total    L1Hit   L1Miss       Lcl       Rmt  Ld Miss    Loads       FB       L1       L2       Llc       Rmt
  # ..................  .......  .......  .......  .......  .......  .......  .......  .......  ........  ........  .......  .......  .......  .......  .......  ........  ........
  #
    0xffff88000235f840       17    0.00%        0        0        0       17       17        0         0         0        0        0        0        0        0         0         0
  ...

  =================================================
        Shared Cache Line Distribution Pareto
  =================================================
  #
  # ----- HITM -----  -- Store Refs --        Data address                                  ---------- cycles ----------       cpu                                   Shared
  #     Rmt      Lcl   L1 Hit  L1 Miss              Offset      Pid                    Tid  rmt hitm  lcl hitm      load       cnt                Symbol             Object  Node
  # .......  .......  .......  .......  ..................  .......  .....................  ........  ........  ........  ........  ....................  .................  ....
  #
    ------------------------------------------------------
          0        0       17        0  0xffff88000235f840
    ------------------------------------------------------
      0.00%    0.00%    5.88%    0.00%                 0x0    11474    11474:kworker/u16:5         0         0         0         1  [k] rmap_walk_file             [kernel.kallsyms]   0
      0.00%    0.00%    5.88%    0.00%                0x10    11474    11474:kworker/u16:5         0         0         0         1  [k] lock_page_memcg            [kernel.kallsyms]   0
      0.00%    0.00%   11.76%    0.00%                0x20    11474    11474:kworker/u16:5         0         0         0         1  [k] page_mapping               [kernel.kallsyms]   0
      0.00%    0.00%   64.71%    0.00%                0x28    11474    11474:kworker/u16:5         0         0         0         1  [k] __test_set_page_writeback  [kernel.kallsyms]   0
      0.00%    0.00%   11.76%    0.00%                0x30    11474    11474:kworker/u16:5         0         0         0         1  [k] page_mapped                [kernel.kallsyms]   0
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-eorco9r0oeesjve77pkkg43s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 22dd59d145 perf c2c report: Set final resort fields
Set resort/display fields for both cachelines and single cacheline
displays.

Cachelines are sorted on:

  rmt_hitm

will be made configurable in following patches.

Following fields are display for cachelines:

  dcacheline
  tot_recs
  percent_hitm
  tot_hitm,lcl_hitm,rmt_hitm
  stores,stores_l1hit,stores_l1miss
  dram_lcl,dram_rmt
  ld_llcmiss
  tot_loads
  ld_fbhit,ld_l1hit,ld_l2hit
  ld_lclhit,ld_rmthit

The single cacheline is sort by:

  offset,rmt_hitm,lcl_hitm

will be made configurable in following patches.

Following fields are display for each cacheline:

  percent_rmt_hitm
  percent_lcl_hitm
  percent_stores_l1hit
  percent_stores_l1miss
  offset
  pid
  tid
  mean_rmt
  mean_lcl
  mean_load
  cpucnt
  symbol
  dso
  node

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-0rclftliywdq9qr2sjbugb6b@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 1d62fcd693 perf c2c report: Setup number of header lines for hists
Allow to setup number of header lines for c2c hists objects.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-4ilsf0ulubrd4y96g7tnpwzk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 89d9ba8f58 perf c2c report: Add src line sort key
It is to be displayed in the single cacheline output:

  cl_srcline

It displays source line related to the code address that accessed
cacheline. It's a wrapper to global srcline sort entry.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-cmnzgm37mjz56ozsg4mnbgxq@git.kernel.org
[ Remove __maybe_unused from now used 'he' parameter in filter_cb() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa b6fe2bbc34 perf c2c report: Add 'cpucnt' sort key
It is to be displayed in the single cacheline output:

  cpucnt

It displays number of distinct cpus that hit cacheline.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-ib2kdwam52fby9u2k3ij6lhm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 92062d543f perf c2c report: Add stats related sort keys
It is to be displayed in the single cacheline output:

  median, mean_rmt, mean_lcl, mean_load, stddev

It displays statistics hits related to cacheline accesses.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-m1r4uc9lcykf1jhpvwk2gkj8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 1e181b92a2 perf c2c report: Add 'node' sort key
It is to be displayed in the single cacheline output:

  node

It displays nodes hits related to cacheline accesses.

The node filed comes in 3 flavors:
  - node IDs separated by ','
  - node IDs with stats for each ID, in following format:
      Node{cpus %hitms %stores}
  - node IDs with list of affected CPUs in following format:
      Node{cpu list}

User can switch the flavor with -N option (-NN,-NNN).
It will be available in TUI to switch this with 'n' key.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-6742e6g0r7n63y5wc4rrgxx5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 51dedaa446 perf c2c report: Add 'symbol' and 'dso' sort keys
They are to be displayed in the single cacheline output:

  symbol, dso

They are wrappers for global sort_sym and sort_dso sort entries with c2c
specific headers.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-6742e6g0r7n63y5wc4rrgxx5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa e87019c5e8 perf c2c report: Add 'tid' sort key
It is to be displayed in the single cacheline output:

  tid

It's a wrapper for global sort_thread sort entry with c2c specific
header.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-fr0socae5skzvz5qbkl85prn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00
Jiri Olsa 36d3deb9d6 perf c2c report: Add 'pid' sort key
It is to be displayed in the single cacheline output:

  pid

We currently don't have a single 'pid' sort/display entry, which would
output just pid number, hence adding it into c2c code.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-3o23qrspxc99b04ci1swlzr6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-10-19 13:18:31 -03:00