1. 30 5月, 2020 13 次提交
    • S
      perf tools: Add optional support for libpfm4 · 70943490
      Stephane Eranian 提交于
      This patch links perf with the libpfm4 library if it is available and
      LIBPFM4 is passed to the build. The libpfm4 library contains hardware
      event tables for all processors supported by perf_events. It is a helper
      library that helps convert from a symbolic event name to the event
      encoding required by the underlying kernel interface. This library is
      open-source and available from: http://perfmon2.sf.net.
      
      With this patch, it is possible to specify full hardware events by name.
      Hardware filters are also supported. Events must be specified via the
      --pfm-events and not -e option. Both options are active at the same time
      and it is possible to mix and match:
      
        $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....
      
      One needs to explicitely ask for its inclusion by using the LIBPFM4 make
      command line option, ie its opt-in rather than opt-out of feature
      detection and build support.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70943490
    • E
      perf tools: Correct license on jsmn JSON parser · 82352ae2
      Ed Maste 提交于
      This header is part of the jsmn JSON parser, introduced in 867a979a.
      Correct the SPDX tag to indicate that it is under the MIT license.
      Signed-off-by: NEd Maste <emaste@freebsd.org>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: http://lore.kernel.org/lkml/20200528170858.48457-1-emaste@freefall.freebsd.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82352ae2
    • N
      perf jit: Fix inaccurate DWARF line table · 1e4bd2ae
      Nick Gasson 提交于
      Fix an issue where addresses in the DWARF line table are offset by -0x40
      (GEN_ELF_TEXT_OFFSET). This can be seen with `objdump -S` on the ELF
      files after perf inject.
      
      Committer notes:
      
      Ian added this in his Acked-by reply:
      
       ---
      Without too much knowledge this looks good to me. The original code came
      from oprofile's jit support:
      
        https://sourceforge.net/p/oprofile/oprofile/ci/master/tree/opjitconv/debug_line.c#l325
       ---
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200528051916.6722-1-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1e4bd2ae
    • N
      perf jvmti: Remove redundant jitdump line table entries · 7d7e503c
      Nick Gasson 提交于
      For each PC/BCI pair in the JVMTI compiler inlining record table, the
      jitdump plugin emits debug line table entries for every source line in
      the method preceding that BCI. Instead only emit one source line per
      PC/BCI pair. Reported by Ian Rogers. This reduces the .dump size for
      SPECjbb from ~230MB to ~40MB.
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200528054049.13662-1-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7d7e503c
    • A
      perf build: Add NO_SDT=1 to the default set of build tests · 60da3a12
      Arnaldo Carvalho de Melo 提交于
      We forgot to add it, so one would have to explicitely ask for it to be
      run, fix that by adding it to the set of tests that are performed by
      default when one does:
      
        $ make -C tools/perf build-test
      
      It was being exercised only in the make_minimal test, this patch makes
      it be tested in isolation, i.e. disabling only this feature.
      
      Fixes: e26e63be ("perf build: Add sdt feature detection")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      60da3a12
    • A
      perf build: Add NO_LIBCRYPTO=1 to the default set of build tests · 69fbadbe
      Arnaldo Carvalho de Melo 提交于
      We forgot to add it, so one would have to explicitely ask for it to be
      run, fix that by adding it to the set of tests that are performed by
      default when one does:
      
        $ make -C tools/perf build-test
      
      It was being exercised only in the make_minimal test, this patch makes
      it be tested in isolation, i.e. disabling only this feature.
      
      Fixes: 8ee46460 ("perf build: Add libcrypto feature detection")
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      69fbadbe
    • A
      perf build: Add NO_SYSCALL_TABLE=1 to the build tests · 5bc7aac3
      Arnaldo Carvalho de Melo 提交于
      So that we make sure that even on x86-64 and other architectures where
      that is the default method we test build the fallback to libaudit that
      other architectures use.
      
      I.e. now this line got added to:
      
        $ make -C tools/perf build-test
        <SNIP>
             make_no_syscall_tbl_O: cd . && make NO_SYSCALL_TABLE=1 FEATURES_DUMP=/home/acme/git/perf/tools/perf/BUILD_TEST_FEATURE_DUMP -j12 O=/tmp/tmp.W0HtKR1mfr DESTDIR=/tmp/tmp.lNezgCVPzW
        <SNIP>
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5bc7aac3
    • A
      perf build: Remove libaudit from the default feature checks · a88f70de
      Arnaldo Carvalho de Melo 提交于
      Ingo reported that the libaudit was always appearing as OFF:
      
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                          gtk2: [ on  ]
        ...                      libaudit: [ OFF ]
      
      And everything seemed to work, i.e. we were checking for a feature that
      we don't use, causing confusion for people building perf, so work to
      remove that nuisance while making sure that it works when an arch
      doesn't provide the alternative method to generate the syscall id/name
      conversion tables.
      
      Longer explanation of the new modus operandi:
      
        $ make -C tools/perf O=/tmp/build/perf NO_SYSCALL_TABLE=1
        <SNIP>
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                          gtk2: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
      
        Makefile.config:665: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
          GEN      /tmp/build/perf/common-cmds.h
          MKDIR    /tmp/build/perf/fd/
          MKDIR    /tmp/build/perf/fs/
        <SNIP>
        $
      
      The libaudit test is forced and it fails when audit-libs-devel isn't available:
      
        $ cat /tmp/build/perf/feature/test-libaudit.make.output
        test-libaudit.c:2:10: fatal error: libaudit.h: No such file or directory
            2 | #include <libaudit.h>
              |          ^~~~~~~~~~~~
        compilation terminated.
        $
      
      If we install audit-libs-devel and rebuild it continues not to be shown as OFF
      in the main auto-detection summary, but again gets tested and this time:
      
        $ rpm -q audit-libs-devel
        audit-libs-devel-3.0-0.15.20191104git1c2f876.fc31.x86_64
        $
      
      The make output for the feature detection comes clean:
      
        $ cat /tmp/build/perf/feature/test-libaudit.make.output
      
      And the feature detection binary is successfully built and is dynamicly linked
      with libaudit:
      
        $ ldd /tmp/build/perf/feature/test-libaudit.bin | grep audit
        	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f5bf5177000)
        $
      
      As well as the resulting perf binary:
      
        $ ldd /tmp/build/perf/perf | grep audit
        	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fad511c7000)
        $
      
      And 'perf trace' works using the libaudit method:
      
        $ sudo /tmp/build/perf/perf trace -e nanosleep sleep 1
             0.000 (1000.067 ms): sleep/281872 nanosleep(rqtp: 0x7ffedbbe69d0) = 0
        $
      
      If we leave audit-libs-devel installed but don't disable the use of the best
      method, the one using SYSCALL_TABLE, the default for architectures that provide
      the script to build the syscall id/name mapping using the .tbl files copied
      from the kernel sources, we get:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ make -C tools/perf O=/tmp/build/perf
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                          gtk2: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
      
          GEN      /tmp/build/perf/common-cmds.h
        <SNIP>
        $
      
      Again, no mention of libaudit being on or OFF and:
      
        $ cat /tmp/build/perf/feature/test-libaudit.make.output
        cat: /tmp/build/perf/feature/test-libaudit.make.output: No such file or directory
        $
      
      We didn't even bother checking for its availability, slightly speeding up the
      build process and:
      
        $ ldd /tmp/build/perf/perf | grep libaudit
        $
      
      We don't link with it, also:
      
        $ sudo /tmp/build/perf/perf trace -e nanosleep sleep 1
             0.000 (1000.053 ms): sleep/299125 nanosleep(rqtp: 0x7ffc24611b50) = 0
        $
      
      And globs become available:
      
        $ sudo /tmp/build/perf/perf trace -e *sleep sleep 1
             0.000 (1000.072 ms): sleep/299136 nanosleep(rqtp: 0x7ffe7a3c4ff0) = 0
        $
      Reported-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a88f70de
    • A
      perf trace: Grow the syscall table as needed when using libaudit · d21cb73a
      Arnaldo Carvalho de Melo 提交于
      The audit-libs API doesn't provide a way to figure out what is the
      syscall with the greatest number/id, take that into account when using
      that method to go on growing the syscall table as we the syscalls go on
      appearing on the radar.
      
      With this the libaudit based method is back working, i.e. when building
      with:
      
        $ make NO_SYSCALL_TABLE=1 O=/tmp/build/perf -C tools/perf install-bin
        <SNIP>
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        $ ldd ~/bin/perf | grep audit
      	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007faef22df000)
        $
      
      perf trace is back working, which makes it functional in arches other
      than x86_64, powerpc, arm64 and s390, that provides these generators:
      
        $ find tools/perf/arch/ -name "*syscalltbl*"
        tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
        tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
        tools/perf/arch/s390/entry/syscalls/mksyscalltbl
        tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
        $
      
      Example output forcing the libaudit method on x86_64:
      
        # perf trace -e file,nanosleep sleep 0.001
                 ? (         ): sleep/859090  ... [continued]: execve())                                   = 0
             0.045 ( 0.005 ms): sleep/859090 access(filename: 0x8733e850, mode: R)                         = -1 ENOENT (No such file or directory)
             0.055 ( 0.005 ms): sleep/859090 openat(dfd: CWD, filename: 0x8733ba29, flags: RDONLY|CLOEXEC) = 3
             0.079 ( 0.005 ms): sleep/859090 openat(dfd: CWD, filename: 0x87345d20, flags: RDONLY|CLOEXEC) = 3
             0.085 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483f58, count: 832)                  = 832
             0.090 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483b50, count: 784)                  = 784
             0.094 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483b20, count: 32)                   = 32
             0.098 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483ad0, count: 68)                   = 68
             0.109 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483a50, count: 784)                  = 784
             0.113 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483730, count: 32)                   = 32
             0.117 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483710, count: 68)                   = 68
             0.320 ( 0.008 ms): sleep/859090 openat(dfd: CWD, filename: 0x872c3660, flags: RDONLY|CLOEXEC) = 3
             0.372 ( 1.057 ms): sleep/859090 nanosleep(rqtp: 0x7ffd9d484ac0)                               = 0
        #
      
      There are still some limitations when using the libaudit method, that
      will be fixed at some point, i.e., this works with the mksyscalltbl
      method but not with libaudit's:
      
        # perf trace -e file,*sleep sleep 0.001
        event syntax error: '*sleep'
                             \___ parser error
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d21cb73a
    • A
      perf trace: Use zalloc() to make sure all fields are zeroed in the syscalltbl constructor · a9e8c1f8
      Arnaldo Carvalho de Melo 提交于
      In the past this wasn't needed as the libaudit based code would use just
      one field, and the alternative constructor would fill in all the fields,
      but now that even when using the libaudit based method we need the other
      fields, switch to zalloc() to make sure the other fields are zeroed at
      instantiation time.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9e8c1f8
    • A
      perf trace: Remove union from syscalltbl, all the fields are needed · db6b8cc8
      Arnaldo Carvalho de Melo 提交于
      When we moved to a syscalltbl generated from the kernel syscall tables
      (arch/..../syscall*.tbl) the idea was to either use it, when having the
      generator (e.g. tools/perf/arch/x86/entry/syscalls/syscalltbl.sh), or
      falling back to the previous audit-libs based way of mapping syscall ids
      to strings and the other way around.
      
      At first we just needed the audit_detect_machine() return to then use it
      to the str->id/id->str, or the other fields for the now used by default
      in the most well developed arches method of using the syscall table
      generator.
      
      The problem is that then the libaudit code fell into disrepair, and
      architectures where it is the method used are not working.
      
      Now, with NO_SYSCALL_TABLE=1 being possible to pass on the make command
      line we can automate the testing of that method even on x86-64, arm64,
      etc.
      
      And doing it I noted that we actually use fields in both entries in the
      union, oops, so ditch the union, as we need all those fields at the same
      time.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      db6b8cc8
    • A
      perf build: Allow explicitely disabling the NO_SYSCALL_TABLE variable · 43de3869
      Arnaldo Carvalho de Melo 提交于
      This is useful to see if, on x86, the legacy libaudit still works, as it
      is used in architectures that don't have the SYSCALL_TABLE logic and we
      want to have it tested in 'make -C tools/perf/ build-test'.
      
      E.g.:
      
      Without having audit-libs-devel installed:
      
        $ make NO_SYSCALL_TABLE=1 O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
        <SNIP>
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ OFF ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        Makefile.config:664: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
        <SNIP>
      
      After installing it:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ time make NO_SYSCALL_TABLE=1 O=/tmp/build/perf  -C tools/perf install-bin ; perf test python
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
          HOSTCC   /tmp/build/perf/fixdep.o
          HOSTLD   /tmp/build/perf/fixdep-in.o
          LINK     /tmp/build/perf/fixdep
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.h' differs from latest version at 'tools/lib/bpf/hashmap.h'
        diff -u tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.c' differs from latest version at 'tools/lib/bpf/hashmap.c'
        diff -u tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
      
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        $ ldd ~/bin/perf | grep audit
        	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fc18978e000)
        $
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200529155552.463-3-acme@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43de3869
    • A
      perf build: Group the NO_SYSCALL_TABLE logic · 9b90d973
      Arnaldo Carvalho de Melo 提交于
      To help in allowing to disable it from the make command line.
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200529155552.463-2-acme@kernel.org
      [ Fixed the logic for the filter part, it should be ifeq, not ifneq ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b90d973
  2. 28 5月, 2020 27 次提交
    • A
      perf intel-pt: Refine kernel decoding only warning message · 9b2d2066
      Adrian Hunter 提交于
      Stop the message displaying when user space is not being traced.
      
      Example:
      
        Prerequisites:
      
          sudo setcap "cap_sys_rawio,cap_sys_admin,cap_sys_ptrace,cap_syslog,cap_ipc_lock=ep" ~/bin/perf
          sudo chmod +r /proc/kcore
      
        Before:
      
          $ perf record --no-switch-events --kcore -a -e intel_pt//k -- sleep 0.001
          Warning:
          Intel Processor Trace decoding will not be possible except for kernel tracing!
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.838 MB perf.data ]
      
        After:
      
          $ perf record --no-switch-events --kcore -a -e intel_pt//k -- sleep 0.001
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 1.068 MB perf.data ]
      
          $ sudo chmod go-r /proc/kcore
          $ sudo setcap -r ~/bin/perf
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Link: http://lore.kernel.org/lkml/20200528120859.21604-2-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b2d2066
    • A
      perf record: Respect --no-switch-events · 16b4b4e1
      Adrian Hunter 提交于
      Context switch events are added automatically by Intel PT and Coresight.
      
      Make it possible to suppress them. That is useful for tracing the
      scheduler without the disturbance that the switch event processing
      creates.
      
      Example:
      
        Prerequisites:
      
          $ which perf
          ~/bin/perf
          $ sudo setcap "cap_sys_rawio,cap_sys_admin,cap_sys_ptrace,cap_syslog,cap_ipc_lock=ep" ~/bin/perf
          $ sudo chmod +r /proc/kcore
      
        Before:
      
          $ perf record --no-switch-events --kcore -a -e intel_pt//k -- sleep 0.001
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.938 MB perf.data ]
          $ perf script -D | grep PERF_RECORD_SWITCH | wc -l
          572
      
        After:
      
          $ perf record --no-switch-events --kcore -a -e intel_pt//k -- sleep 0.001
          Warning:
          Intel Processor Trace decoding will not be possible except for kernel tracing!
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.838 MB perf.data ]
          $ perf script -D | grep PERF_RECORD_SWITCH | wc -l
          0
      
          $ sudo chmod go-r /proc/kcore
          $ sudo setcap -r ~/bin/perf
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Link: http://lore.kernel.org/lkml/20200528120859.21604-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      16b4b4e1
    • A
      perf script: Fix --call-trace for Intel PT · b5164085
      Adrian Hunter 提交于
      Make process_attr() respect -F-ip, noting also that the condition in
      process_attr() (callchain_param.record_mode != CALLCHAIN_NONE) is always
      true so test the sample type directly.
      
      Example:
      
        Before:
      
          $ perf record -e intel_pt//u uname
          Linux
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.033 MB perf.data ]
          $ perf script --call-trace | head -5
                 uname 30992 [006] 41758.313696574:  cbr: 42 freq: 4219 MHz (156%)                    0 [unknown] ([unknown]                                         )
                 uname 30992 [006] 41758.313696907: _start                               7f71792c4100 _start+0x0 (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )
                 uname 30992 [006] 41758.313699574:     _dl_start                        7f71792c4103 _start+0x3 (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )
                 uname 30992 [006] 41758.313699907:     _dl_start                        7f71792c4e18 _dl_start+0x28 (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )
                 uname 30992 [006] 41758.313701574:     _dl_start                        7f71792c5128 _dl_start+0x338 (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )
      
        After:
      
          $ perf script --call-trace | head -5
                 uname 30992 [006] 41758.313696574:  cbr: 42 freq: 4219 MHz (156%)
                 uname 30992 [006] 41758.313696907: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )      _start
                 uname 30992 [006] 41758.313699574: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
                 uname 30992 [006] 41758.313699907: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
                 uname 30992 [006] 41758.313701574: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
      
      Fixes: f288e8e1aa4f ("perf script: Enable IP fields for callchains")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20200527180250.16723-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b5164085
    • A
      perf evlist: Disable 'immediate' events last · 87cf8360
      Adrian Hunter 提交于
      Events marked as 'immediate' are started before other events to ensure
      that there is context at the start of the main tracing events. The same
      is true at the end of tracing, so disable 'immediate' events after other
      events.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: x86@kernel.org
      Link: http://lore.kernel.org/lkml/20200512121922.8997-11-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      87cf8360
    • A
      perf kcore_copy: Fix module map when there are no modules loaded · 61f82e3f
      Adrian Hunter 提交于
      In the absence of any modules, no "modules" map is created, but there
      are other executable pages to map, due to eBPF JIT, kprobe or ftrace.
      Map them by recognizing that the first "module" symbol is not
      necessarily from a module, and adjust the map accordingly.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: x86@kernel.org
      Link: http://lore.kernel.org/lkml/20200512121922.8997-10-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      61f82e3f
    • N
      perf jvmti: Fix demangling Java symbols · 0bdf3181
      Nick Gasson 提交于
      For a Java method signature like:
      
          Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V
      
      The demangler produces:
      
          void class java.lang.AbstractStringBuilder.appendChars(class java.lang., shorttring., int, int)
      
      The arguments should be (java.lang.String, int, int) but the demangler
      interprets the "S" in String as the type code for "short". Correct this
      and two other minor things:
      
      - There is no "bool" type in Java, should be "boolean".
      
      - The demangler prepends "class" to every Java class name. This is not
        standard Java syntax and it wastes a lot of horizontal space if the
        signature is long. Remove this as there isn't any ambiguity between
        class names and primitives.
      
      Committer notes:
      
      This was split from a larger patch that also added a java demangler
      'perf test' entry, that, before this patch shows the error being fixed
      by it:
      
        $ perf test java
        65: Demangle Java                                         : FAILED!
        $ perf test -v java
        Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
        65: Demangle Java                                         :
        --- start ---
        test child forked, pid 307264
        FAILED: Ljava/lang/StringLatin1;equals([B[B)Z: bool class java.lang.StringLatin1.equals(byte[], byte[]) != boolean java.lang.StringLatin1.equals(byte[], byte[])
        FAILED: Ljava/util/zip/ZipUtils;CENSIZ([BI)J: long class java.util.zip.ZipUtils.CENSIZ(byte[], int) != long java.util.zip.ZipUtils.CENSIZ(byte[], int)
        FAILED: Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z: bool class java.util.regex.Pattern$BmpCharProperty.match(class java.util.regex.Matcher., int, class java.lang., charhar, shortequence) != boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)
        FAILED: Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V: void class java.lang.AbstractStringBuilder.appendChars(class java.lang., shorttring., int, int) != void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)
        FAILED: Ljava/lang/Object;<init>()V: void class java.lang.Object<init>() != void java.lang.Object<init>()
        test child finished with -1
        ---- end ----
        Demangle Java: FAILED!
        $
      
      After applying this patch:
      
        $ perf test  java
        65: Demangle Java                                         : Ok
        $
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200427061520.24905-4-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0bdf3181
    • N
      perf tests: Add test for the java demangler · 525c821d
      Nick Gasson 提交于
      Split from a larger patch that was also fixing a problem with the java
      demangler, so, before applying that patch we see:
      
        $ perf test java
        65: Demangle Java                                         : FAILED!
        $ perf test -v java
        65: Demangle Java                                         :
        --- start ---
        test child forked, pid 307264
        FAILED: Ljava/lang/StringLatin1;equals([B[B)Z: bool class java.lang.StringLatin1.equals(byte[], byte[]) != boolean java.lang.StringLatin1.equals(byte[], byte[])
        FAILED: Ljava/util/zip/ZipUtils;CENSIZ([BI)J: long class java.util.zip.ZipUtils.CENSIZ(byte[], int) != long java.util.zip.ZipUtils.CENSIZ(byte[], int)
        FAILED: Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z: bool class java.util.regex.Pattern$BmpCharProperty.match(class java.util.regex.Matcher., int, class java.lang., charhar, shortequence) != boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)
        FAILED: Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V: void class java.lang.AbstractStringBuilder.appendChars(class java.lang., shorttring., int, int) != void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)
        FAILED: Ljava/lang/Object;<init>()V: void class java.lang.Object<init>() != void java.lang.Object<init>()
        test child finished with -1
        ---- end ----
        Demangle Java: FAILED!
        $
      
      Next patch should fix this.
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200427061520.24905-4-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      525c821d
    • N
      perf jvmti: Do not report error when missing debug information · 959f8ed4
      Nick Gasson 提交于
      If the Java sources are compiled with -g:none to disable debug
      information the perf JVMTI plugin reports a lot of errors like:
      
        java: GetLineNumberTable failed with JVMTI_ERROR_ABSENT_INFORMATION
        java: GetLineNumberTable failed with JVMTI_ERROR_ABSENT_INFORMATION
        java: GetLineNumberTable failed with JVMTI_ERROR_ABSENT_INFORMATION
        java: GetLineNumberTable failed with JVMTI_ERROR_ABSENT_INFORMATION
        java: GetLineNumberTable failed with JVMTI_ERROR_ABSENT_INFORMATION
      
      Instead if GetLineNumberTable returns JVMTI_ERROR_ABSENT_INFORMATION
      simply skip emitting line number information for that method. Unlike the
      previous patch these errors don't affect the jitdump generation, they
      just generate a lot of noise.
      
      Similarly for native methods which also don't have line tables.
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Tested-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200427061520.24905-3-nick.gasson@arm.com
      [ Moved || operator to the end of the line, not at the start of 2nd if condition ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      959f8ed4
    • N
      perf jvmti: Fix jitdump for methods without debug info · 953e9240
      Nick Gasson 提交于
      If a Java class is compiled with -g:none to omit debug information, the
      JVMTI plugin won't write jitdump entries for any method in this class
      and prints a lot of errors like:
      
          java: GetSourceFileName failed with JVMTI_ERROR_ABSENT_INFORMATION
      
      The call to GetSourceFileName is used to derive the file name `fn`, but
      this value is not actually used since commit ca58d7e6 ("perf jvmti:
      Generate correct debug information for inlined code") which moved the
      file name lookup into fill_source_filenames(). So the call to
      GetSourceFileName and related code can be safely removed.
      Signed-off-by: NNick Gasson <nick.gasson@arm.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Tested-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200427061520.24905-2-nick.gasson@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      953e9240
    • A
      perf symbols: Fix debuginfo search for Ubuntu · 85afd355
      Adrian Hunter 提交于
      Reportedly, from 19.10 Ubuntu has begun mixing up the location of some
      debug symbol files, putting files expected to be in
      /usr/lib/debug/usr/lib into /usr/lib/debug/lib instead. Fix by adding
      another dso_binary_type.
      
      Example on Ubuntu 20.04
      
        Before:
      
          $ perf record -e intel_pt//u uname
          Linux
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.030 MB perf.data ]
          $ perf script --call-trace | head -5
                 uname 14003 [005] 15321.764958566:  cbr: 42 freq: 4219 MHz (156%)
                 uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          7f1e71cc4100
                 uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )              7f1e71cc4df0
                 uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )              7f1e71cc4e18
                 uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )              7f1e71cc5128
      
        After:
      
          $ perf script --call-trace | head -5
                 uname 14003 [005] 15321.764958566:  cbr: 42 freq: 4219 MHz (156%)
                 uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )      _start
                 uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
                 uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
                 uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so              )          _dl_start
      Reported-by: NTravis Downs <travis.downs@gmail.com>
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200526155207.9172-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      85afd355
    • J
      perf parse: Add 'struct parse_events_state' pointer to scanner · 1244a327
      Jiri Olsa 提交于
      We need to pass more data to the scanner so let's start with having it
      to take pointer to 'struct parse_events_state' object instead of just
      start token.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200524224219.234847-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1244a327
    • J
      perf stat: Do not pass avg to generic_metric · 5f09ca5a
      Jiri Olsa 提交于
      There's no need to pass the given evsel's count to metric data, because
      it will be pushed again within the following metric_events loop.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200524224219.234847-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5f09ca5a
    • J
      perf tests: Consider subtests when searching for user specified tests · d685e6c1
      Jiri Olsa 提交于
      It's now possible to put subtest name as a test filter:
      
        $ perf test 'PMU event table sanity'
        10: PMU events                                            :
        10.1: PMU event table sanity                              : Ok
      
      Committer testing:
      
      Before:
      
        $ perf test 'PMU event table sanity'
        $
      
      After:
      
        $ perf test 'PMU event table sanity'
        10: PMU events                                            :
        10.1: PMU event table sanity                              : Ok
        $
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200524224219.234847-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d685e6c1
    • I
      perf list: Add metrics to command line usage · a90a1c54
      Ian Rogers 提交于
      Before:
      
       Usage: perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|event_glob]
      
      After:
      
       Usage: perf list [<options>] [hw|sw|cache|tracepoint|pmu|sdt|metric|metricgroup|event_glob]
      
      Committer testing:
      
      Before and after we get these outputs on a Lenovo t480s (i7-8650U):
      
        # perf list metricgroup
      
        List of pre-defined events (to be used in -e):
      
        Metric Groups:
      
        BrMispredicts
        BrMispredicts_SMT
        Branches
        Cache_Misses
        DSB
        FLOPS
        FLOPS_SMT
        Fetch_BW
        IcMiss
        Instruction_Type
        Memory_BW
        Memory_Bound
        Memory_Lat
        No_group
        PGO
        Pipeline
        Power
        Retire
        SMT
        Summary
        TLB
        TLB_SMT
        TopDownL1
        TopDownL1_SMT
        TopdownL1
        TopdownL1_SMT
        #
      
        # perf list metric | head -11
      
        Metrics:
      
          Backend_Bound
               [This category represents fraction of slots where no uops are being delivered due to a lack of required resources for accepting new uops in the Backend]
          Backend_Bound_SMT
               [This category represents fraction of slots where no uops are being delivered due to a lack of required resources for accepting new uops in the Backend. SMT version; use when SMT is enabled and measuring per logical CPU]
          Bad_Speculation
               [This category represents fraction of slots wasted due to incorrect speculations]
          Bad_Speculation_SMT
               [This category represents fraction of slots wasted due to incorrect speculations. SMT version; use when SMT is enabled and measuring per logical CPU]
        #
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200522064546.164259-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a90a1c54
    • A
      perf script: Don't force less for non tty output with --xed · 8c3e05c8
      Andi Kleen 提交于
      --xed currently forces less. When piping the output to other scripts
      this can waste a lot of CPU time because less is rather slow.
      I've seen it using up a full core on its own in a pipeline.
      Only force less when the output is actually a terminal.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Link: http://lore.kernel.org/lkml/20200522020914.527564-1-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8c3e05c8
    • I
      perf metricgroup: Remove unnecessary ',' from events · e2ce1059
      Ian Rogers 提交于
      Remove unnecessary commas from events before they are parsed. This
      avoids ',' being echoed by parse-events.l.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-8-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e2ce1059
    • I
      perf metricgroup: Add options to not group or merge · 05530a79
      Ian Rogers 提交于
      Add --metric-no-group that causes all events within metrics to not be
      grouped. This can allow the event to get more time when multiplexed, but
      may also lower accuracy.
      Add --metric-no-merge option. By default events in different metrics may
      be shared if the group of events for one metric is the same or larger
      than that of the second. Sharing may increase or lower accuracy and so
      is now configurable.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-7-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      05530a79
    • I
      perf metricgroup: Remove duped metric group events · 2440689d
      Ian Rogers 提交于
      A metric group contains multiple metrics. These metrics may use the same
      events. If metrics use separate events then it leads to more
      multiplexing and overall metric counts fail to sum to 100%.
      
      Modify how metrics are associated with events so that if the events in
      an earlier group satisfy the current metric, the same events are used.
      A record of used events is kept and at the end of processing unnecessary
      events are eliminated.
      
      Before:
      
        $ perf stat -a -M TopDownL1 sleep 1
      
         Performance counter stats for 'system wide':
      
             920,211,343   uops_issued.any             #      0.5 Backend_Bound   (16.56%)
           1,977,733,128   idq_uops_not_delivered.core                            (16.56%)
              51,668,510   int_misc.recovery_cycles                               (16.56%)
             732,305,692   uops_retired.retire_slots                              (16.56%)
           1,497,621,849   cycles                                                 (16.56%)
             721,098,274   uops_issued.any             #      0.1 Bad_Speculation (16.79%)
           1,332,681,791   cycles                                                 (16.79%)
             552,475,482   uops_retired.retire_slots                              (16.79%)
              47,708,340   int_misc.recovery_cycles                               (16.79%)
           1,383,713,292   cycles
                                                       #      0.4 Frontend_Bound  (16.76%)
           2,013,757,701   idq_uops_not_delivered.core                            (16.76%)
           1,373,363,790   cycles
                                                       #      0.1 Retiring        (33.54%)
             577,302,589   uops_retired.retire_slots                              (33.54%)
             392,766,987   inst_retired.any            #      0.3 IPC             (50.24%)
           1,351,873,350   cpu_clk_unhalted.thread                                (50.24%)
           1,332,510,318   cycles
                                                       # 5330041272.0 SLOTS       (49.90%)
      
             1.006336145 seconds time elapsed
      
      After:
      
        $ perf stat -a -M TopDownL1 sleep 1
      
         Performance counter stats for 'system wide':
      
             765,949,145   uops_issued.any             #      0.1 Bad_Speculation
                                                       #      0.5 Backend_Bound   (50.09%)
           1,883,830,591   idq_uops_not_delivered.core #      0.3 Frontend_Bound  (50.09%)
              48,237,080   int_misc.recovery_cycles                               (50.09%)
             581,798,385   uops_retired.retire_slots   #      0.1 Retiring        (50.09%)
           1,361,628,527   cycles
                                                       # 5446514108.0 SLOTS       (50.09%)
             391,415,714   inst_retired.any            #      0.3 IPC             (49.91%)
           1,336,486,781   cpu_clk_unhalted.thread                                (49.91%)
      
             1.005469298 seconds time elapsed
      
      Note: Bad_Speculation + Backend_Bound + Frontend_Bound + Retiring = 100%
      after, where as before it is 110%. After there are 2 groups, whereas
      before there are 6. After the cycles event appears once, before it
      appeared 5 times.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-6-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2440689d
    • I
      perf metricgroup: Order event groups by size · 6bf2102b
      Ian Rogers 提交于
      When adding event groups to the group list, insert them in size order.
      This performs an insertion sort on the group list. By placing the
      largest groups at the front of the group list it is possible to see if a
      larger group contains the same events as a later group. This can make
      the later group redundant - it can reuse the events from the large
      group.  A later patch will add this sharing.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6bf2102b
    • I
      perf metricgroup: Delay events string creation · 7f9eca51
      Ian Rogers 提交于
      Currently event groups are placed into groups_list at the same time as
      the events string containing the events is built. Separate these two
      operations and build the groups_list first, then the event string from
      the groups_list. This adds an ability to reorder the groups_list that
      will be used in a later patch.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-4-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f9eca51
    • I
      perf metricgroup: Use early return in add_metric · 90810399
      Ian Rogers 提交于
      Use early return in metricgroup__add_metric and try to make the intent
      of the returns more intention revealing.
      Suggested-by: NJiri Olsa <jolsa@redhat.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-3-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      90810399
    • I
      perf metricgroup: Always place duration_time last · 4e21c13a
      Ian Rogers 提交于
      If a metric contains the duration_time event then the event is placed
      outside of the metric's group of events. Rather than split the group,
      make it so the duration_time is immediately after the group.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200520182011.32236-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4e21c13a
    • I
      perf metricgroup: Free metric_events on error · a159e2fe
      Ian Rogers 提交于
      Avoid a simple memory leak.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: kp singh <kpsingh@chromium.org>
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200508053629.210324-10-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a159e2fe
    • L
      perf util: Fix potential SEGFAULT in put_tracepoints_path error path · fa99ce82
      Li Bin 提交于
      This patch fix potential segment fault triggered in
      put_tracepoints_path() when the address of the local variable 'path' be
      freed in error path of record_saved_cmdline.
      Signed-off-by: NLi Bin <huawei.libin@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hongbo Yao <yaohongbo@huawei.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Xie XiuQi <xiexiuqi@huawei.com>
      Link: http://lore.kernel.org/lkml/20200521133218.30150-5-liwei391@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fa99ce82
    • X
      perf util: Fix memory leak of prefix_if_not_in · 07e9a6f5
      Xie XiuQi 提交于
      Need to free "str" before return when asprintf() failed to avoid memory
      leak.
      Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hongbo Yao <yaohongbo@huawei.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200521133218.30150-4-liwei391@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      07e9a6f5
    • C
      perf ftrace: Detect workload failure · 51a09d8f
      Changbin Du 提交于
      Currently there's no error message prompted if we failed to start
      workload.  And we still get some trace which is confusing. Let's tell
      users what happened.
      
      Committer testing:
      
      Before:
      
          # perf ftrace nonsense |& head
           5)               |  switch_mm_irqs_off() {
           5)   0.400 us    |    load_new_mm_cr3();
           5)   3.261 us    |  }
           ------------------------------------------
           5)    <idle>-0    =>   <...>-3494
           ------------------------------------------
      
           5)               |  finish_task_switch() {
           5)   ==========> |
           5)               |    smp_irq_work_interrupt() {
          # type nonsense
          -bash: type: nonsense: not found
          #
      
      After:
      
        # perf ftrace nonsense |& head
        workload failed: No such file or directory
        # type nonsense
        -bash: type: nonsense: not found
        #
      Signed-off-by: NChangbin Du <changbin.du@gmail.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lore.kernel.org/lkml/20200510150628.16610-3-changbin.du@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      51a09d8f
    • C
      perf ftrace: Trace system wide if no target is given · 452b0d16
      Changbin Du 提交于
      This align ftrace to other perf sub-commands that if no target specified
      then we trace all functions.
      Signed-off-by: NChangbin Du <changbin.du@gmail.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lore.kernel.org/lkml/20200510150628.16610-2-changbin.du@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      452b0d16