15 Mar, 2016

1 commit

  • Pull perf updates from Ingo Molnar:
    "Main kernel side changes:

    - Big reorganization of the x86 perf support code. The old code grew
    organically deep inside arch/x86/kernel/cpu/perf* and its naming
    became somewhat messy.

    The new location is under arch/x86/events/, using the following
    cleaner hierarchy of source code files:

    perf/x86: Move perf_event.c .................. => x86/events/core.c
    perf/x86: Move perf_event_amd.c .............. => x86/events/amd/core.c
    perf/x86: Move perf_event_amd_ibs.c .......... => x86/events/amd/ibs.c
    perf/x86: Move perf_event_amd_iommu.[ch] ..... => x86/events/amd/iommu.[ch]
    perf/x86: Move perf_event_amd_uncore.c ....... => x86/events/amd/uncore.c
    perf/x86: Move perf_event_intel_bts.c ........ => x86/events/intel/bts.c
    perf/x86: Move perf_event_intel.c ............ => x86/events/intel/core.c
    perf/x86: Move perf_event_intel_cqm.c ........ => x86/events/intel/cqm.c
    perf/x86: Move perf_event_intel_cstate.c ..... => x86/events/intel/cstate.c
    perf/x86: Move perf_event_intel_ds.c ......... => x86/events/intel/ds.c
    perf/x86: Move perf_event_intel_lbr.c ........ => x86/events/intel/lbr.c
    perf/x86: Move perf_event_intel_pt.[ch] ...... => x86/events/intel/pt.[ch]
    perf/x86: Move perf_event_intel_rapl.c ....... => x86/events/intel/rapl.c
    perf/x86: Move perf_event_intel_uncore.[ch] .. => x86/events/intel/uncore.[ch]
    perf/x86: Move perf_event_intel_uncore_nhmex.c => x86/events/intel/uncore_nmhex.c
    perf/x86: Move perf_event_intel_uncore_snb.c => x86/events/intel/uncore_snb.c
    perf/x86: Move perf_event_intel_uncore_snbep.c => x86/events/intel/uncore_snbep.c
    perf/x86: Move perf_event_knc.c .............. => x86/events/intel/knc.c
    perf/x86: Move perf_event_p4.c ............... => x86/events/intel/p4.c
    perf/x86: Move perf_event_p6.c ............... => x86/events/intel/p6.c
    perf/x86: Move perf_event_msr.c .............. => x86/events/msr.c

    (Borislav Petkov)

    - Update various x86 PMU constraint and hw support details (Stephane
    Eranian)

    - Optimize kprobes for BPF execution (Martin KaFai Lau)

    - Rewrite, refactor and fix the Intel uncore PMU driver code (Thomas
    Gleixner)

    - Rewrite, refactor and fix the Intel RAPL PMU code (Thomas Gleixner)

    - Various fixes and smaller cleanups.

    There are lots of perf tooling updates as well. A few highlights:

    perf report/top:

    - Hierarchy histogram mode for 'perf top' and 'perf report',
    showing multiple levels, one per --sort entry: (Namhyung Kim)

    On a mostly idle system:

    # perf top --hierarchy -s comm,dso

    Then expand some levels and use 'P' to take a snapshot:

    # cat perf.hist.0
    - 92.32% perf
    58.20% perf
    22.29% libc-2.22.so
    5.97% [kernel]
    4.18% libelf-0.165.so
    1.69% [unknown]
    - 4.71% qemu-system-x86
    3.10% [kernel]
    1.60% qemu-system-x86_64 (deleted)
    + 2.97% swapper
    #

    - Add 'L' hotkey to dynamicly set the percent threshold for
    histogram entries and callchains, i.e. dynamicly do what the
    --percent-limit command line option to 'top' and 'report' does.
    (Namhyung Kim)

    perf mem:

    - Allow specifying events via -e in 'perf mem record', also listing
    what events can be specified via 'perf mem record -e list' (Jiri
    Olsa)

    perf record:

    - Add 'perf record' --all-user/--all-kernel options, so that one
    can tell that all the events in the command line should be
    restricted to the user or kernel levels (Jiri Olsa), i.e.:

    perf record -e cycles:u,instructions:u

    is equivalent to:

    perf record --all-user -e cycles,instructions

    - Make 'perf record' collect CPU cache info in the perf.data file header:

    $ perf record usleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
    $ perf report --header-only -I | tail -10 | head -8
    # CPU cache info:
    # L1 Data 32K [0-1]
    # L1 Instruction 32K [0-1]
    # L1 Data 32K [2-3]
    # L1 Instruction 32K [2-3]
    # L2 Unified 256K [0-1]
    # L2 Unified 256K [2-3]
    # L3 Unified 4096K [0-3]

    Will be used in 'perf c2c' and eventually in 'perf diff' to
    allow, for instance running the same workload in multiple
    machines and then when using 'diff' show the hardware difference.
    (Jiri Olsa)

    - Improved support for Java, using the JVMTI agent library to do
    jitdumps that then will be inserted in synthesized
    PERF_RECORD_MMAP2 events via 'perf inject' pointed to synthesized
    ELF files stored in ~/.debug and keyed with build-ids, to allow
    symbol resolution and even annotation with source line info, see
    the changeset comments to see how to use it (Stephane Eranian)

    perf script/trace:

    - Decode data_src values (e.g. perf.data files generated by 'perf
    mem record') in 'perf script': (Jiri Olsa)

    # perf script
    perf 693 [1] 4.088652: 1 cpu/mem-loads,ldlat=30/P: ffff88007d0b0f40 68100142 L1 hit|SNP None|TLB L1 or L2 hit|LCK No
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    - Improve support to 'data_src', 'weight' and 'addr' fields in
    'perf script' (Jiri Olsa)

    - Handle empty print fmts in 'perf script -s' i.e. when running
    python or perl scripts (Taeung Song)

    perf stat:

    - 'perf stat' now shows shadow metrics (insn per cycle, etc) in
    interval mode too. E.g:

    # perf stat -I 1000 -e instructions,cycles sleep 1
    # time counts unit events
    1.000215928 519,620 instructions # 0.69 insn per cycle
    1.000215928 752,003 cycles

    - Port 'perf kvm stat' to PowerPC (Hemant Kumar)

    - Implement CSV metrics output in 'perf stat' (Andi Kleen)

    perf BPF support:

    - Support converting data from bpf events in 'perf data' (Wang Nan)

    - Print bpf-output events in 'perf script': (Wang Nan).

    # perf record -e bpf-output/no-inherit,name=evt/ -e ./test_bpf_output_3.c/map:channel.event=evt/ usleep 1000
    # perf script
    usleep 4882 21384.532523: evt: ffffffff810e97d1 sys_nanosleep ([kernel.kallsyms])
    BPF output: 0000: 52 61 69 73 65 20 61 20 Raise a
    0008: 42 50 46 20 65 76 65 6e BPF even
    0010: 74 21 00 00 t!..
    BPF string: "Raise a BPF event!"
    #

    - Add API to set values of map entries in a BPF object, be it
    individual map slots or ranges (Wang Nan)

    - Introduce support for the 'bpf-output' event (Wang Nan)

    - Add glue to read perf events in a BPF program (Wang Nan)

    - Improve support for bpf-output events in 'perf trace' (Wang Nan)

    ... and tons of other changes as well - see the shortlog and git log
    for details!"

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (342 commits)
    perf stat: Add --metric-only support for -A
    perf stat: Implement --metric-only mode
    perf stat: Document CSV format in manpage
    perf hists browser: Check sort keys before hot key actions
    perf hists browser: Allow thread filtering for comm sort key
    perf tools: Add sort__has_comm variable
    perf tools: Recalc total periods using top-level entries in hierarchy
    perf tools: Remove nr_sort_keys field
    perf hists browser: Cleanup hist_browser__fprintf_hierarchy_entry()
    perf tools: Remove hist_entry->fmt field
    perf tools: Fix command line filters in hierarchy mode
    perf tools: Add more sort entry check functions
    perf tools: Fix hist_entry__filter() for hierarchy
    perf jitdump: Build only on supported archs
    tools lib traceevent: Add '~' operation within arg_num_eval()
    perf tools: Omit unnecessary cast in perf_pmu__parse_scale
    perf tools: Pass perf_hpp_list all the way through setup_sort_list
    perf tools: Fix perf script python database export crash
    perf jitdump: DWARF is also needed
    perf bench mem: Prepare the x86-64 build for upstream memcpy_mcsafe() changes
    ...

    Linus Torvalds
     

11 Mar, 2016

15 commits

  • Add metric only support for -A too. This requires a new print function
    that prints the metrics in the right order.

    v2: Fix manpage
    v3: Simplify nrcpus computation

    Signed-off-by: Andi Kleen
    Acked-by: Jiri Olsa
    Link: http://lkml.kernel.org/r/1457049458-28956-7-git-send-email-andi@firstfloor.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     
  • Add a new mode to only print metrics. Sometimes we don't care about the
    raw values, just want the computed metrics. This allows more compact
    printing, so with -I each sample is only a single line. This also
    allows easier plotting and processing with other tools.

    The main target is with using --topdown, but it also works with -T and
    standard perf stat. A few metrics are not supported.

    To avoiding having to hardcode all the metrics in the code it uses a two
    pass approach: first compute dummy metrics and only print the headers in
    the print_metric callback. Then use the callback to print the actual
    values.

    There are some additional changes in the stat printout code to handle
    all metrics being on a single line.

    One issue is that the column code doesn't know in advance what events
    are not supported by the CPU, and it would be hard to find out as this
    could change based on dynamic conditions. That causes empty columns in
    some cases.

    The output can be fairly wide, often you may need more than 80 columns.

    Example:

    % perf stat -a -I 1000 --metric-only
    1.001452803 frontend cycles idle insn per cycle stalled cycles per insn branch-misses of all branches
    1.001452803 158.91% 0.66 2.39 2.92%
    2.002192321 180.63% 0.76 2.08 2.96%
    3.003088282 150.59% 0.62 2.57 2.84%
    4.004369835 196.20% 0.98 1.62 3.79%
    5.005227314 231.98% 0.84 1.90 4.71%

    v2: Lots of updates.
    v3: Use slightly narrower columns
    v4: Add comment

    Signed-off-by: Andi Kleen
    Acked-by: Jiri Olsa
    Link: http://lkml.kernel.org/r/1457049458-28956-6-git-send-email-andi@firstfloor.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     
  • With all the recently added fields in the perf stat CSV output we should
    finally document them in the man page. Do this here.

    v2: Fix fields in documentation (Jiri)
    v3: fix order of fields again (Jiri)
    v4: Change order again.
    v5: Document more fields (Jiri)
    v6: Move time stamp first
    v7: More fixes (Jiri)

    Signed-off-by: Andi Kleen
    Acked-by: Jiri Olsa
    Link: http://lkml.kernel.org/r/1457049458-28956-5-git-send-email-andi@firstfloor.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     
  • The context menu in TUI hists browser checks corresponding sort keys
    when creating the menu item. But hotkey actions lacks these checks so
    it can filter using incorrect info.

    For example, default sort key of 'perf top' doesn't contain 'comm' or
    'pid' sort key so each hist entry's thread info is not reliable. Thus
    it should prohibit using thread filter on 't' key.

    Signed-off-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1457533253-21419-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • The commit 2eafd410e669 ("perf hists browser: Only 'Zoom into thread'
    only when sort order has 'pid'") disabled thread filtering in hist
    browser for the default sort key. However the he->thread is still valid
    even if 'pid' sort key is not given. Only thing it should not use is
    the pid (or tid) of the thread. So allow to filter by thread when
    'comm' sort key is given and show pid only if 'pid' sort key is given.

    Signed-off-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1457536490-24084-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • The sort__has_comm variable is to check whether the comm sort key is
    given. This is necessary to support thread filtering in the TUI hists
    browser later.

    Signed-off-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1457533253-21419-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • When hierarchy mode is enabled, each entry in a hierarchy level shares
    the period. IOW an upper level entry's period is the sum of lower level
    entries. Thus perf uses only one of them to calculate the total period
    of hists. It was lowest-level (leaf) entries but it has a problem when
    it comes to filters.

    If a filter is applied, entries in the same level will be filtered or
    not. But upper level entries still have period of their sum including
    filtered one. So total sum of upper level entries will not be same as
    sum of lower level entries.

    This resulted in entries having more than 100% of overhead and it can be
    produced using perf top with filter(s).

    Reported-and-Tested-by: Jiri Olsa
    Signed-off-by: Namhyung Kim
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-8-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • The nr_sort_keys field is to carry the number of sort entries in a
    hpp_list or hists to determine the depth of indentation of a hist entry.
    As it's only used in hierarchy mode and now we have used nr_hpp_node for
    this reason, there's no need to keep it anymore. Let's get rid of it.

    Signed-off-by: Namhyung Kim
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-7-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • The hist_browser__fprintf_hierarchy_entry() if to dump current output
    into a file so it needs to be sync-ed with the corresponding function
    hist_browser__show_hierarchy_entry(). So use hists->nr_hpp_node to
    indent width and use first fmt_node to print overhead columns instead of
    checking whether it's a sort entry (or dynamic entry).

    Signed-off-by: Namhyung Kim
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-6-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • It's not used anymore and the output format is accessed by the hpp_list
    pointer instead when hierarchy is enabled. Let's get rid of it.

    Signed-off-by: Namhyung Kim
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-5-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • When a command-line filter is applied in hierarchy mode, output is
    broken especially when filtering on lower level. The higher level
    entries doesn't show up so it's hard to see the results.

    Also it needs to handle multi sort keys in a single hierarchy level.

    Before:

    $ perf report --hierarchy -s 'cpu,{dso,comm}' --comms swapper --stdio
    ...
    # Overhead CPU / Shared Object+Command
    # ........... ...........................
    #
    13.79% [kernel.vmlinux] swapper
    31.71% 000
    13.80% [kernel.vmlinux] swapper
    0.43% [e1000e] swapper
    11.89% [kernel.vmlinux] swapper
    9.18% [kernel.vmlinux] swapper

    After:

    # Overhead CPU / Shared Object+Command
    # ........... ...............................
    #
    33.09% 003
    13.79% [kernel.vmlinux] swapper
    31.71% 000
    13.80% [kernel.vmlinux] swapper
    0.43% [e1000e] swapper
    21.90% 002
    11.89% [kernel.vmlinux] swapper
    13.30% 001
    9.18% [kernel.vmlinux] swapper

    Signed-off-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-4-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Those functions are for checkinf if a given perf_hpp_fmt is a
    filter-related sort entry. With hierarchy mode, it needs to check
    filters on the hist entries with its own hpp format list.

    Signed-off-by: Namhyung Kim
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • When hierarchy mode is enabled each output format is in a separate hpp
    list. So when applying a filter it should check all formats in the
    list. Currently it only checks a single ->fmt field which was not set
    properly.

    Signed-off-by: Namhyung Kim
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457531222-18130-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Build jitdump only on architectures defined in util/genelf.h file, to avoid
    breaking the build on such arches.

    Signed-off-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Borislav Petkov
    Cc: Colin Ian King
    Cc: David Ahern
    Cc: Davidlohr Bueso
    Cc: He Kuang
    Cc: Mel Gorman
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Steven Rostedt
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/20160310164113.GA11357@krava.redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • When evaluating values for print flags, if the value included a '~'
    operator, the parsing would fail. This broke kmalloc's parsing of:

    __print_flags(REC->gfp_flags, "|", {(unsigned
    long)((((((( gfp_t)(0x400000u|0x2000000u)) | (( gfp_t)0x40u) |
    (( gfp_t)0x80u) | (( gfp_t)0x20000u)) | (( gfp_t)0x02u)) |
    (( gfp_t)0x08u)) | (( gfp_t)0x4000u) | (( gfp_t)0x10000u) |
    (( gfp_t)0x1000u) | (( gfp_t)0x200u)) & ~(( gfp_t)0x2000000u))
    ^
    |
    here

    Signed-off-by: Steven Rostedt
    Reported-by: Arnaldo Carvalho de Melo
    Tested-by: David Ahern
    Cc: Andi Kleen
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/20160226181328.22f47129@gandalf.local.home
    Signed-off-by: Arnaldo Carvalho de Melo

    Steven Rostedt
     

09 Mar, 2016

5 commits

  • There's no need to use a const char pointer, we can used char pointer
    from the beginning and omit the unnecessary cast.

    Reported-by: Ingo Molnar
    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: H. Peter Anvin
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20160308184230.GB7897@krava.redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Pass perf_hpp_list all the way through setup_sort_list so that the sort
    entry can be added on the arbitrary list.

    Signed-off-by: Jiri Olsa
    Acked-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20160309100417.GA30910@krava.redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Remove the union in evsel so that the database id and priv pointer can
    be used simultainously without conflicting and crashing.

    Detailed Description for the fixed bug follows:

    perf script crashes with a segmentation fault on user space tool version
    4.5.rc7.ge2857b when using the python database export API. It works
    properly in 4.4 and prior versions.

    the crash fist appeared in:

    cfc8874a4859 ("perf script: Process cpu/threads maps")

    How to reproduce the bug:

    Remove any temporary files left over from a previous crash (if you have
    already attemped to reproduce the bug):

    $ rm -r test_db-perf-data
    $ dropdb test_db

    $ perf record timeout 1 yes >/dev/null
    $ perf script -s scripts/python/export-to-postgresql.py test_db

    Stack Trace:
    Program received signal SIGSEGV, Segmentation fault.
    __GI___libc_free (mem=0x1) at malloc.c:2929
    2929 malloc.c: No such file or directory.
    (gdb) bt
    at util/stat.c:122
    argv=, prefix=) at builtin-script.c:2231
    argc=argc@entry=4, argv=argv@entry=0x7fffffffdf70) at perf.c:390
    at perf.c:451

    Signed-off-by: Chris Phlipot
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Peter Zijlstra
    Fixes: cfc8874a4859 ("perf script: Process cpu/threads maps")
    Link: http://lkml.kernel.org/r/1457500314-8912-1-git-send-email-cphlipot0@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Chris Phlipot
     
  • While building on a Docker container for ubuntu and installing package
    by package one ends up with:

    MKDIR /tmp/build/util/
    CC /tmp/build/util/genelf.o
    util/genelf.c:22:19: fatal error: dwarf.h: No such file or directory
    #include
    ^
    compilation terminated.
    mv: cannot stat '/tmp/build/util/.genelf.o.tmp': No such file or directory

    Because the jitdump code needs the DWARF related development packages to
    be installed. So make it dependent on that so that the build can succeed
    without jitdump support.

    Cc: Adrian Hunter
    Cc: Stephane Eranian
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-le498robnmxd40237wej3w62@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • The following upcoming upstream commit:

    92b0729c34ca ("x86/mm, x86/mce: Add memcpy_mcsafe()")

    Adds _ASM_EXTABLE_FAULT(), which is not available in user-space
    and breaks the build.

    We don't really need _ASM_EXTABLE_FAULT() in user-space, so simply
    wrap it to nothing.

    Cc: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Hitoshi Mitake
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

08 Mar, 2016

15 commits

  • Now hpp formats are linked using perf_hpp_list_node when hierarchy is
    enabled. Like in stdio, use this info to print entries with multiple
    sort keys in a single hierarchy properly.

    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-8-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • Now hpp formats are linked using perf_hpp_list_node when hierarchy is
    enabled. Like in stdio, use this info to print entries with multiple
    sort keys in a single hierarchy properly.

    Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-7-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • Now hpp formats are linked using perf_hpp_list_node when hierarchy is
    enabled. Use this info to print entries with multiple sort keys in a
    single hierarchy properly.

    For example, the below example shows using 4 sort keys with 2 levels.

    $ perf report --hierarchy -s '{prev_pid,prev_comm},{next_pid,next_comm}' \
    --percent-limit 1 -i perf.data.sched
    ...
    # Overhead prev_pid+prev_comm / next_pid+next_comm
    # ........... .......................................
    #
    22.36% 0 swapper/0
    9.48% 17773 transmission-gt
    5.25% 109 kworker/0:1H
    1.53% 6524 Xephyr
    21.39% 17773 transmission-gt
    9.52% 0 swapper/0
    9.04% 0 swapper/2
    1.78% 0 swapper/3

    Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-6-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • When multiple sort keys are used in a single hierarchy, it should indent
    using number of hierarchy levels instead of number of sort keys.

    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-5-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • This implements having multiple sort keys in a single hierarchy level.
    Originally only single sort key is supported for each level, but now
    using the group syntax with '{ }', it can set more than one sort key in
    one level. Note that now it needs to quote in order to prevent shell
    interpretation.

    For example:

    $ perf report --hierarchy -s '{comm,dso},sym'
    ...
    # Overhead Command / Shared Object / Symbol
    # .............. ..........................................
    #
    48.67% swapper [kernel.vmlinux]
    34.42% [k] intel_idle
    1.30% [k] __tick_nohz_idle_enter
    1.03% [k] cpuidle_reflect
    8.87% firefox libpthread-2.22.so
    6.60% [.] __GI___libc_recvmsg
    1.18% [.] pthread_cond_signal@@GLIBC_2.3.2
    1.09% [.] 0x000000000000ff4b
    6.11% Xorg libc-2.22.so
    5.27% [.] __memcpy_sse2_unaligned

    In the above example, the command name and the shared object name are
    shown on the same line but the symbol name is on the different line.
    Since the first two are grouped by '{}', they are in the same level.

    Suggested-and-Tested=by: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-4-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • Now each hists has its own hpp lists in hierarchy. So instead of having
    a pointer to a single perf_hpp_fmt in a hist entry, make it point the
    hpp_list for its level. This will be used to support multiple sort keys
    in a single hierarchy level.

    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • The perf_hpp__setup_hists_formats() is to build hists-specific output
    formats (and sort keys). Currently it's only used in order to build the
    output format in a hierarchy with same sort keys, but it could be used
    with different sort keys in non-hierarchy mode later.

    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457361308-514-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • I'm surprised this remained undocumented since at least 2011. And it is
    actually a very useful switch, as Steve and I came to realize recently.

    Add the text from

    2cba3ffb9a9d ("perf stat: Add -d -d and -d -d -d options to show more CPU events")

    which added the incrementing aspect to -d.

    Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Borislav Petkov
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Davidlohr Bueso
    Cc: Jiri Olsa
    Cc: Mel Gorman
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Fixes: 2cba3ffb9a9d ("perf stat: Add -d -d and -d -d -d options to show more CPU events")
    Link: http://lkml.kernel.org/r/1457347294-32546-1-git-send-email-bp@alien8.de
    Signed-off-by: Ingo Molnar

    Borislav Petkov
     
  • The level field is to distinguish levels in the hierarchy mode.
    Currently each column (perf_hpp_fmt) has a different level.

    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457103582-28396-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Ingo Molnar

    Namhyung Kim
     
  • Commit b9511cd761fa ("perf/x86: Fix time_shift in perf_event_mmap_page")
    altered the time conversion algorithms documented in the perf_event.h
    header file, to use 64-bit shifts. That was done to make the code more
    future-proof (i.e. some time in the future a 32-bit shift could be
    allowed). Reflect those changes in perf tools.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1457005856-6143-9-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Ingo Molnar

    Adrian Hunter
     
  • Move clockid validation into jit_process() so it can later be made
    conditional.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1457005856-6143-6-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Ingo Molnar

    Adrian Hunter
     
  • In preparation for moving clockid validation into jit_process().

    Previously a return value of zero meant the processing had been done and
    non-zero meant either the processing was not done (i.e. not the jitdump
    file mmap event) or an error occurred.

    Change it so that zero means the processing was not done, one means the
    processing was done and successful, and negative values are an error.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1457005856-6143-5-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Ingo Molnar

    Adrian Hunter
     
  • Some of the stubs are identical so just have one function for them.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1457005856-6143-3-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Ingo Molnar

    Adrian Hunter
     
  • Currently, when injecting build ids, if there is AUX data then 'perf
    inject' hits all DSOs because it is not known which DSOs the trace data
    would hit.

    That needs to be done for JIT injection also, and in fact there is no
    reason to distinguish what kind of injection is being done. That is,
    any time there is AUX data and the HEADER_BUID_ID feature flag is set,
    and the AUX data is not being processed, then hit all DSOs. This patch
    does that.

    Signed-off-by: Adrian Hunter
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1457005856-6143-2-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Ingo Molnar

    Adrian Hunter
     
  • The return type is not defined, so it defaults to int, however, the
    function is not returning anything, so this is clearly not correct. Make
    it a void function.

    Signed-off-by: Colin Ian King
    Signed-off-by: Arnaldo Carvalho de Melo
    Acked-by: Jiri Olsa
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: He Kuang
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1457008214-14393-1-git-send-email-colin.king@canonical.com
    Signed-off-by: Ingo Molnar

    Colin Ian King
     

03 Mar, 2016

4 commits

  • Add an extra check for frontend stalled in the metrics. This avoids an
    extra column for the --metric-only case when the CPU does not support
    frontend stalled.

    v2: Add separate init function

    Signed-off-by: Andi Kleen
    Acked-by: Jiri Olsa
    Link: http://lkml.kernel.org/r/1456858672-21594-8-git-send-email-andi@firstfloor.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Andi Kleen
     
  • When building with gcc 6 we're getting various build warnings that just
    require some trivial function declaration and call fixes:

    turbostat.c: In function ‘dump_cstate_pstate_config_info’:
    turbostat.c:1973:1: warning: type of ‘family’ defaults to ‘int’
    dump_cstate_pstate_config_info(family, model)
    turbostat.c:1973:1: warning: type of ‘model’ defaults to ‘int’
    turbostat.c: In function ‘get_tdp’:
    turbostat.c:2145:8: warning: type of ‘model’ defaults to ‘int’
    double get_tdp(model)
    turbostat.c: In function ‘perf_limit_reasons_probe’:
    turbostat.c:2259:6: warning: type of ‘family’ defaults to ‘int’
    void perf_limit_reasons_probe(family, model)
    turbostat.c:2259:6: warning: type of ‘model’ defaults to ‘int’

    Signed-off-by: Colin Ian King
    Cc: Matt Fleming
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/n/tip-wbicer8n0s9qe6ql8h9x478e@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Colin Ian King
     
  • The sa_flags field is not being initialized, so a garbage value is being
    passed to sigaction. Initialize it to zero.

    Signed-off-by: Colin Ian King
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1456923322-29697-1-git-send-email-colin.king@canonical.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Colin Ian King
     
  • That got broken by d3a72fd8187b ("perf report: Fix indentation of
    dynamic entries in hierarchy"), by using the evlist in setup_sorting()
    without checking if it is NULL, as done in some 'perf test' entries:

    $ find tools/ -name "*.c" | xargs grep 'setup_sorting(NULL);'
    tools/perf/tests/hists_output.c: setup_sorting(NULL);
    tools/perf/tests/hists_output.c: setup_sorting(NULL);
    tools/perf/tests/hists_output.c: setup_sorting(NULL);
    tools/perf/tests/hists_output.c: setup_sorting(NULL);
    tools/perf/tests/hists_output.c: setup_sorting(NULL);
    tools/perf/tests/hists_cumulate.c: setup_sorting(NULL);
    tools/perf/tests/hists_cumulate.c: setup_sorting(NULL);
    tools/perf/tests/hists_cumulate.c: setup_sorting(NULL);
    tools/perf/tests/hists_cumulate.c: setup_sorting(NULL);
    $

    Fix it.

    Before:

    [root@jouet ~]# perf test

    15: Test matching and linking multiple hists : FAILED!
    16: Try 'import perf' in python, checking link problems : Ok
    17: Test breakpoint overflow signal handler : Ok
    18: Test breakpoint overflow sampling : Ok
    19: Test number of exit event of a simple workload : Ok
    20: Test software clock events have valid period values : Ok
    21: Test object code reading : Ok
    22: Test sample parsing : Ok
    23: Test using a dummy software event to keep tracking : Ok
    24: Test parsing with no sample_id_all bit set : Ok
    25: Test filtering hist entries : FAILED!
    26: Test mmap thread lookup : Ok
    27: Test thread mg sharing : Ok
    28: Test output sorting of hist entries : FAILED!
    29: Test cumulation of child hist entries : FAILED!

    After the patch the above failed tests complete successfully.

    Acked-by: Namhyung Kim
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Wang Nan
    Fixes: d3a72fd8187b ("perf report: Fix indentation of dynamic entries in hierarchy")
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo