1. 14 Mar, 2023 23 commits
    • Ian Rogers's avatar
      perf vendor events intel: Update graniterapids events · b720bf90
      Ian Rogers authored
      Update from 1.00 to 1.01, some event description updates.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Edward Baker <edward.baker@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230314053312.3237390-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b720bf90
    • Roman Lozko's avatar
      perf scripts intel-pt-events.py: Fix IPC output for Python 2 · 1f64cfde
      Roman Lozko authored
      Integers are not converted to floats during division in Python 2 which
      results in incorrect IPC values. Fix by switching to new division
      behavior.
      
      Fixes: a483e64c ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
      Signed-off-by: default avatarRoman Lozko <lozko.roma@gmail.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/20230310150445.2925841-1-lozko.roma@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f64cfde
    • Arnaldo Carvalho de Melo's avatar
      perf tools bpf: Add vmlinux.h to .gitignore · 0e70f50e
      Arnaldo Carvalho de Melo authored
      Now that BPF skel based tools will be built by default if the toolchain
      pieces that are needed are available, building directly on the source
      tree will produce a vmlinux.h from the BTF info that needs to get
      ignored.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0e70f50e
    • Ian Rogers's avatar
      perf test: Fix "PMU event table sanity" for NO_JEVENTS=1 · 07fc5921
      Ian Rogers authored
      A table was renamed and needed to be renamed in the empty case.
      
      Fixes: 62774db2 ("perf jevents: Generate metrics and events as separate tables")
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230308002714.1755698-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      07fc5921
    • Namhyung Kim's avatar
      perf lock contention: Show lock type with address · 4f701063
      Namhyung Kim authored
      Show lock type names after the symbol of locks if any.  This can be
      useful especially when it doesn't show the lock symbols.
      
      The indentation before the lock type parenthesis is to recognize lock
      symbols more easily.
      
        $ sudo ./perf lock con -abl -- sleep 1
         contended   total wait     max wait     avg wait            address   symbol
      
                44      6.13 ms    284.49 us    139.28 us   ffffffff92e06080   tasklist_lock (rwlock)
               159    983.38 us     12.38 us      6.18 us   ffff8cc717c90000   siglock (spinlock)
                10    679.90 us    153.35 us     67.99 us   ffff8cdc2872aaf8   mmap_lock (rwsem)
                 9    558.11 us    180.67 us     62.01 us   ffff8cd647914038   mmap_lock (rwsem)
                78    228.56 us      7.82 us      2.93 us   ffff8cc700061c00    (spinlock)
                 5     41.60 us     16.93 us      8.32 us   ffffd853acb41468    (spinlock)
                10     37.24 us      5.87 us      3.72 us   ffff8cd560b5c200   siglock (spinlock)
                 4     11.17 us      3.97 us      2.79 us   ffff8d053ddf0c80   rq_lock (spinlock)
                 1      7.86 us      7.86 us      7.86 us   ffff8cd64791404c    (spinlock)
                 1      4.13 us      4.13 us      4.13 us   ffff8d053d930c80   rq_lock (spinlock)
                 7      3.98 us      1.67 us       568 ns   ffff8ccb92479440    (mutex)
                 2      2.62 us      2.33 us      1.31 us   ffff8cc702e6ede0    (rwlock)
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230313204825.2665483-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f701063
    • Namhyung Kim's avatar
      perf lock contention: Show per-cpu rq_lock with address · d24c0144
      Namhyung Kim authored
      Using the BPF_PROG_RUN mechanism, we can run a raw_tp BPF program to
      collect some semi-global locks like per-cpu locks.  Let's add runqueue
      locks using bpf_per_cpu_ptr() helper.
      
        $ sudo ./perf lock con -abl -- sleep 1
         contended   total wait     max wait     avg wait            address   symbol
      
               248      3.25 ms     32.23 us     13.10 us   ffff8cc75cfd2940   siglock
                60    217.91 us      9.69 us      3.63 us   ffff8cc700061c00
                 8     70.23 us     13.86 us      8.78 us   ffff8cc703629484
                 4     56.32 us     35.81 us     14.08 us   ffff8cc78b66f778   mmap_lock
                 4     16.70 us      5.18 us      4.18 us   ffff8cc7036a0684
                 3      4.99 us      2.65 us      1.66 us   ffff8d053da30c80   rq_lock
                 2      3.44 us      2.28 us      1.72 us   ffff8d053dcf0c80   rq_lock
                 9      2.51 us       371 ns       278 ns   ffff8ccb92479440
                 2      2.11 us      1.24 us      1.06 us   ffff8d053db30c80   rq_lock
                 2      2.06 us      1.69 us      1.03 us   ffff8d053d970c80   rq_lock
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230313204825.2665483-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d24c0144
    • Namhyung Kim's avatar
      perf lock contention: Track and show siglock with address · 1811e827
      Namhyung Kim authored
      Likewise, we can display siglock by following the pointer like
      current->sighand->siglock.
      
        $ sudo ./perf lock con -abl -- sleep 1
         contended   total wait     max wait     avg wait            address   symbol
      
                16      2.18 ms    305.35 us    136.34 us   ffffffff92e06080   tasklist_lock
                28    521.78 us     31.16 us     18.63 us   ffff8cc703783ec4
                 7    119.03 us     23.55 us     17.00 us   ffff8ccb92479440
                15     88.29 us     10.06 us      5.89 us   ffff8cd560b5f380   siglock
                 7     37.67 us      9.16 us      5.38 us   ffff8d053daf0c80
                 5      8.81 us      4.92 us      1.76 us   ffff8d053d6b0c80
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230313204825.2665483-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1811e827
    • Namhyung Kim's avatar
      perf lock contention: Track and show mmap_lock with address · 3ace2435
      Namhyung Kim authored
      Sometimes there are severe contentions on the mmap_lock and we want
      see it in the -l/--lock-addr output.  However it cannot symbolize
      the mmap_lock because it's allocated dynamically without symbols.
      
      Stephane and Hao gave me an idea separately to display mmap_lock by
      following the current->mm pointer.  I added a flag to mark mmap_lock
      after comparing the lock address so that it can show them differently.
      With this change it can show mmap_lock like below:
      
        $ sudo ./perf lock con -abl -- sleep 10
         contended   total wait     max wait     avg wait            address   symbol
         ...
             16344    312.30 ms      2.22 ms     19.11 us   ffff8cc702595640
             17686    310.08 ms      1.49 ms     17.53 us   ffff8cc7025952c0
                 3     84.14 ms     45.79 ms     28.05 ms   ffff8cc78114c478   mmap_lock
              3557     76.80 ms     68.75 us     21.59 us   ffff8cc77ca3af58
                 1     68.27 ms     68.27 ms     68.27 ms   ffff8cda745dfd70
                 9     54.53 ms      7.96 ms      6.06 ms   ffff8cc7642a48b8   mmap_lock
             14629     44.01 ms     60.00 us      3.01 us   ffff8cc7625f9ca0
              3481     42.63 ms    140.71 us     12.24 us   ffffffff937906ac   vmap_area_lock
             16194     38.73 ms     42.15 us      2.39 us   ffff8cd397cbc560
                11     38.44 ms     10.39 ms      3.49 ms   ffff8ccd6d12fbb8   mmap_lock
                 1      5.43 ms      5.43 ms      5.43 ms   ffff8cd70018f0d8
              1674      5.38 ms    422.93 us      3.21 us   ffffffff92e06080   tasklist_lock
               581      4.51 ms    130.68 us      7.75 us   ffff8cc9b1259058
                 5      3.52 ms      1.27 ms    703.23 us   ffff8cc754510070
               112      3.47 ms     56.47 us     31.02 us   ffff8ccee38b3120
               381      3.31 ms     73.44 us      8.69 us   ffffffff93790690   purge_vmap_area_lock
               255      3.19 ms     36.35 us     12.49 us   ffff8d053ce30c80
      
      Note that mmap_lock was renamed some time ago and it needs to support
      old kernels with a different name 'mmap_sem'.
      Suggested-by: default avatarHao Luo <haoluo@google.com>
      Suggested-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230313204825.2665483-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3ace2435
    • Ian Rogers's avatar
      perf build: Error if no libelf and NO_LIBELF isn't set · 8d98ca5c
      Ian Rogers authored
      Building without libelf support is going disable a lot of
      functionality. Require that the NO_LIBELF=1 build option is passed if
      this is intentional.
      
      Committer notes:
      
      Add NO_LIBELF=1 to the 'make_static' target in tools/perf/tests/make so
      that 'make -C tools/perf build-test' works.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d98ca5c
    • Ian Rogers's avatar
      perf build: Remove redundant NO_NEWT build option · f1925bd5
      Ian Rogers authored
      The option controlled nothing and no code depends, conditional or
      otherwise, on libnewt.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f1925bd5
    • Ian Rogers's avatar
      perf build: If libtraceevent isn't present error the build · 6898e60f
      Ian Rogers authored
      If libtraceevent isn't present, the build will warn and continue. This
      disables a number of features and so isn't desirable. This change
      makes the build error for this case. The build can still be made to
      happen by adding NO_LIBTRACEEVENT=1.
      
      Committer notes:
      
      Add NO_LIBTRACEEVENT=1 to the 'make_static' target in
      tools/perf/tests/make so that 'make -C tools/perf build-test' works.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6898e60f
    • Ian Rogers's avatar
      perf build: Switch libpfm4 to opt-out rather than opt-in · d7c4f89a
      Ian Rogers authored
      If libpfm4 passes the feature test, it would be nice to have it
      enabled rather than also requiring the LIBPFM4=1 build flag.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d7c4f89a
    • Ian Rogers's avatar
      perf symbol: Add abi::__cxa_demangle C++ demangling support · 3b4e4efe
      Ian Rogers authored
      Refactor C++ demangling out of symbol-elf into its own files similar
      to other languages. Add abi::__cxa_demangle support. As the other
      demanglers are not shippable with distributions, this brings back C++
      demangling in a common case. It isn't perfect as the support for
      optionally demangling arguments and modifiers isn't present.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3b4e4efe
    • Ian Rogers's avatar
      tools build: Add feature test for abi::__cxa_demangle · 4c72e2b3
      Ian Rogers authored
      cxxabi.h is part of libsdtc++ and LLVM's libcxx, providing
      abi::__cxa_demangle a portable C++ demangler. Add a feature test to
      detect that the function is available.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4c72e2b3
    • Ian Rogers's avatar
      perf build: Make binutil libraries opt in · dd317df0
      Ian Rogers authored
      binutils is GPLv3 so distributions cannot ship perf linked against
      libbfd and libiberty as the licenses are incompatible. Rather than
      defaulting the build to opting in to libbfd and libiberty support and
      opting out via NO_LIBBFD=1 and NO_DEMANGLE=1, make building against
      the libraries optional and enabled with BUILD_NONDISTRO=1.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dd317df0
    • Ian Rogers's avatar
      perf build: Error if jevents won't work and NO_JEVENTS=1 isn't set · 175f9315
      Ian Rogers authored
      Rather than disabling jevents if a sufficient python isn't present
      error in the build. This avoids the build progressing but the binary
      being degraded. The build can still succeed by specifying NO_JEVENTS=1
      to the build and this is conveyed in the error message.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      175f9315
    • Ian Rogers's avatar
      perf util: Remove weak sched_getcpu · 0cd3142f
      Ian Rogers authored
      sched_getcpu may not be present and so a feature test and definition
      exist to workaround this in the build. The feature test is used to
      define HAVE_SCHED_GETCPU_SUPPORT and so this is sufficient to know
      whether the local sched_getcpu is needed and a weak symbol can be
      avoided.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0cd3142f
    • Ian Rogers's avatar
      perf build: Remove unused HAVE_GLIBC_SUPPORT · 7bafa03f
      Ian Rogers authored
      HAVE_GLIBC_SUPPORT is only used in `perf version --build-options` but
      doesn't control any behavior. Remove from the build to simplify it.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7bafa03f
    • Ian Rogers's avatar
      perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL · a980755b
      Ian Rogers authored
      BPF skeleton support is now key to a number of perf features. Rather
      than making it so that BPF support must be enabled for the build, make
      this the default and error if the build lacks a clang and libbpf that
      are sufficient. To avoid the error and build without BPF skeletons the
      NO_BPF_SKEL=1 flag can be used. Add a build-options flag to 'perf
      version' to enable detection of the BPF skeleton support and use this
      in the offcpu shell test.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a980755b
    • Ian Rogers's avatar
      perf build: Support python/perf.so testing · 7a9b223c
      Ian Rogers authored
      Add a build target to echo the python/perf.so's name from
      Makefile.perf. Use it in tests/make so the correct target is built and
      tested for.
      
      Fixes: caec5470 ("perf build: Fix python/perf.so library's name")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a9b223c
    • Ian Rogers's avatar
      perf bpf: Remove pre libbpf 1.0 conditional logic · 6bebc06d
      Ian Rogers authored
      Tests are no longer applicable as libbpf 1.0 can be assumed.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>
      Acked/Tested-by: Jiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Christy Lee <christylee@fb.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6bebc06d
    • Ian Rogers's avatar
      perf build: Remove libbpf pre-1.0 feature tests · 76a97cf2
      Ian Rogers authored
      The feature tests were necessary for libbpf pre-1.0, but as the libbpf
      implies at least 1.0 we can remove these now.
      
      Committer notes:
      
      Modified tools/perf/Makefile.config to better reflect the reason for
      failure when the libbpf present is < 1.0 and LIBBPF_DYNAMIC=1 was asked
      for.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Christy Lee <christylee@fb.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      76a97cf2
    • Ian Rogers's avatar
      tools build: Pass libbpf feature only if libbpf 1.0+ · 56d52294
      Ian Rogers authored
      libbpf 1.0 represented a cleanup and stabilization of APIs. Simplify
      development by only passing the feature test if libbpf 1.0 is installed.
      
      Committer notes:
      
      Change 'make -C tools/perf build-test' so that the LIBBPF_DYNAMIC=1 test
      runs only if libbpf is >= 1.0.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Christy Lee <christylee@fb.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56d52294
  2. 13 Mar, 2023 17 commits
    • Ian Rogers's avatar
      perf lock contention: Fix compiler builtin detection · 17535a33
      Ian Rogers authored
      __has_builtin was passed the macro rather than the actual builtin
      feature. The builtin test isn't sufficient and a clang version test
      also needs to be performed.
      
      Fixes: 1bece135 ("perf lock contention: Support old rw_semaphore type")
      Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <martin.lau@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230308003020.3653271-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      17535a33
    • James Clark's avatar
      perf cs-etm: Avoid printing warning in cs_etm_is_ete() check · e5af1397
      James Clark authored
      When checking for the presence of ETE, a register is read that may not
      be present on older kernels or if ETE isn't available. cs_etm_get_ro()
      will print a warning if it doesn't exist, so check for the existence
      first before accessing it.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230308094843.287093-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e5af1397
    • James Clark's avatar
      perf cs-etm: Reduce verbosity of ts_source warning · 5f968d28
      James Clark authored
      This is printed as a warning but it is normal behavior that users
      shouldn't be expected to do anything about. Reduce the warning level to
      debug3 so it's only seen in verbose mode to avoid confusion.
      
      Reviewed-by: Leo Yan <leo.yan@linaro.org
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Al Grant <al.grant@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230308094843.287093-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5f968d28
    • Thomas Richter's avatar
      perf list: Add PMU pai_ext event description for IBM z16 · d30baf2c
      Thomas Richter authored
      Add the event description for the IBM z16 pai_ext PMU released with
      commit c432fefe ("s390/pai: Add support for PAI Extension 1 NNPA
      counters")
      
      The document SA22-7832-13 "z/Architecture Principles of Operation",
      published May, 2022, contains the description of the
      Processor Activity Instrumentation Facility and the NNPA counter
      set., See Pages 5-113 to 5-116 and chapter 26 for details.
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230308125326.2195613-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d30baf2c
    • Thomas Richter's avatar
      perf vendor events s390: Add cache metrics for z16 · f8a6cea4
      Thomas Richter authored
      Add metrics for s390 z16
      
      - Percentage sourced from Level 2 cache
      - Percentage sourced from Level 3 on same chip cache
      - Percentage sourced from Level 4 Local cache on same book
      - Percentage sourced from Level 4 Remote cache on different book
      - Percentage sourced from memory
      
      For details about the formulas see this documentation:
      https://www.ibm.com/support/pages/system/files/inline-files/CPU%20MF%20Formulas%20including%20z16%20-%20May%202022_1.pdf
      
      Output after:
      
        # ./perf stat -M l4rp -- dd if=/dev/zero of=/dev/null bs=10M count=10K
        .... dd output deleted
      
        Performance counter stats for 'dd if=/dev/zero of=/dev/null bs=10M count=10K':
      
                        0      IDCW_OFF_DRAWER_CHIP_HIT         #     0.00 l4rp
                  431,866      L1I_DIR_WRITES
                    2,395      IDCW_OFF_DRAWER_IV
                        0      ICW_OFF_DRAWER
                        0      IDCW_OFF_DRAWER_DRAWER_HIT
                    1,437      DCW_OFF_DRAWER
              425,960,793      L1D_DIR_WRITES
      
             12.165030699 seconds time elapsed
      
              0.001037000 seconds user
             12.162140000 seconds sys
        #
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-By: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230313080201.2440201-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f8a6cea4
    • Thomas Richter's avatar
      perf vendor events s390: Add common metrics · 74395567
      Thomas Richter authored
      Add 3 metrics for s390 machines:
      
      - Cycles per instruction: Amount of CPU cycles used per instructions,
        named cpi.
      - Problem state ratio: Ratio of instructions executed in problem state
        compared to total number of instructions, named prbstate.
      - Level one instruction and data cache misses per 100 instructions,
        named l1mp.
      
      For details about the formulas see this documentation:
      https://www.ibm.com/support/pages/system/files/inline-files/CPU%20MF%20Formulas%20including%20z16%20-%20May%202022_1.pdf
      
      Output after:
      
        # ./perf stat -M cpi -- dd if=/dev/zero of=/dev/null bs=1M count=10K
        10240+0 records in
        10240+0 records out
        10737418240 bytes (11 GB, 10 GiB) copied, 1.30151 s, 8.2 GB/s
      
        Performance counter stats for 'dd if=/dev/zero of=/dev/null .....':
      
          6,779,778,802      CPU_CYCLES              #     1.96 cpi
          3,461,975,090      INSTRUCTIONS
      
          1.306873021 seconds time elapsed
      
          0.001034000 seconds user
          1.305677000 seconds sys
        #
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Acked-By: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230313080201.2440201-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      74395567
    • Ian Rogers's avatar
      perf parse-events: Warn when events are regrouped · a4c7d7c5
      Ian Rogers authored
      Use if an event is reordered or the number of groups increases to
      signal that regrouping has happened and warn about it. Disable the
      warning in the case wild card PMU names are used and for metrics.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a4c7d7c5
    • Ian Rogers's avatar
      perf evlist: Remove nr_groups · 9d2dc632
      Ian Rogers authored
      Maintaining the number of groups during event parsing is problematic
      and since changing to sort/regroup events can only be computed by a
      linear pass over the evlist. As the value is generally only used in
      tests, rather than hold it in a variable compute it by passing over
      the evlist when necessary.
      
      This change highlights that libpfm's counting of groups with a single
      entry disagreed with regular event parsing. The libpfm tests are
      updated accordingly.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d2dc632
    • Ian Rogers's avatar
      perf evsel: Remove use_uncore_alias · e733f87e
      Ian Rogers authored
      This flag used to be used when regrouping uncore events in particular
      due to wildcard matches. This is now handled by sorting evlist and so
      the flag is redundant.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e733f87e
    • Ian Rogers's avatar
      perf parse-events: Sort and group parsed events · 347c2f0a
      Ian Rogers authored
      This change is intended to be a no-op for most current cases, the
      default sort order is the order the events were parsed. Where it
      varies is in how groups are handled. Previously an uncore and core
      event that are grouped would most often cause the group to be removed:
      
      ```
      $ perf stat -e '{instructions,uncore_imc_free_running_0/data_total/}' -a sleep 1
      WARNING: grouped events cpus do not match, disabling group:
        anon group { instructions, uncore_imc_free_running_0/data_total/ }
      ...
      ```
      
      However, when wildcards are used the events should be re-sorted and
      re-grouped in parse_events__set_leader, but this currently fails for
      simple examples:
      
      ```
      $ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1
      
       Performance counter stats for 'system wide':
      
           <not counted> MiB  uncore_imc_free_running/data_read/
           <not counted> MiB  uncore_imc_free_running/data_write/
      
             1.000996992 seconds time elapsed
      ```
      
      A futher failure mode, fixed in this patch, is to force topdown events
      into a group.
      
      This change moves sorting the evsels in the evlist after parsing. It
      requires parsing to set up groups. First the evsels are sorted
      respecting the existing groupings and parse order, but also reordering
      to ensure evsels of the same PMU and group appear together. So that
      software and aux events respect groups, their pmu_name is taken from
      the group leader. The sorting is done with list_sort removing a memory
      allocation.
      
      After sorting a pass is done to correct the group leaders and for
      topdown events ensuring they have a group leader.
      
      This fixes the problems seen before:
      
      ```
      $ perf stat -e '{uncore_imc_free_running/data_read/,uncore_imc_free_running/data_write/}' -a sleep 1
      
       Performance counter stats for 'system wide':
      
                  727.42 MiB  uncore_imc_free_running/data_read/
                   81.84 MiB  uncore_imc_free_running/data_write/
      
             1.000948615 seconds time elapsed
      ```
      
      As well as making groups not fail for cases like:
      
      ```
      $ perf stat -e '{imc_free_running_0/data_total/,imc_free_running_1/data_total/}' -a sleep 1
      
       Performance counter stats for 'system wide':
      
                  256.47 MiB  imc_free_running_0/data_total/
                  256.48 MiB  imc_free_running_1/data_total/
      
             1.001165442 seconds time elapsed
      ```
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      347c2f0a
    • Ian Rogers's avatar
      perf parse-events: Pass ownership of the group name · 4bb311b2
      Ian Rogers authored
      Pass ownership of the group name rather than copying and freeing the
      original. This saves a memory allocation and copy.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4bb311b2
    • Ian Rogers's avatar
      perf evsel: Add function to compute group PMU name · 7abf0bcc
      Ian Rogers authored
      The computed name respects software events and aux event groups, such
      that the pmu_name is changed to be that of the aux event leader or
      group leader for software events. This is done as a later change will
      split events that are in different PMUs into different groups.
      
      Committer notes:
      
      Added a stub for this new function so that 'perf test python' passes.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7abf0bcc
    • Ian Rogers's avatar
      perf evsel: Allow const evsel for certain accesses · c6d616fe
      Ian Rogers authored
      List sorting, added later to evlist, passes const elements requiring
      helper functions to also be const. Make the argument to
      evsel__find_pmu, evsel__is_aux_event and evsel__leader const.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c6d616fe
    • Ian Rogers's avatar
      perf stat: Modify the group test · ce5b8590
      Ian Rogers authored
      Currently nr_members is 0 for an event with no group, however, they
      are always a leader of their own group. A later change will make that
      count 1 because the event is its own leader. Make the find_stat logic
      consistent with this, an improvement suggested by Namhyung Kim.
      Suggested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce5b8590
    • Ian Rogers's avatar
      perf pmu: Earlier PMU auxtrace initialization · 3c7b84d4
      Ian Rogers authored
      This allows event parsing to use the evsel__is_aux_event function,
      which is important when determining event grouping.
      Suggested-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c7b84d4
    • Ian Rogers's avatar
      perf stat: Don't remove all grouped events when CPU maps disagree · bc6c6cdc
      Ian Rogers authored
      If the events in an evlist's CPU map differ then the entire group is
      removed. For example:
      
      ```
      $ perf stat -e '{imc_free_running/data_read/,imc_free_running/data_write/,cs}' -a sleep 1
      WARNING: grouped events cpus do not match, disabling group:
        anon group { imc_free_running/data_read/, imc_free_running/data_write/, cs }
      ```
      
      Change the behavior so that just the events not matching the leader
      are removed. So in the example above, just 'cs' will be removed.
      
      Modify the warning so that it is produced once for each group, rather
      than once for the entire evlist. Shrink the scope and size of the
      warning text buffer.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc6c6cdc
    • Ian Rogers's avatar
      libperf evlist: Avoid a use of evsel idx · 5dd827e0
      Ian Rogers authored
      Setting the leader iterates the list, so rather than use idx (which
      may be changed through list reordering) just count the elements and
      set afterwards.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20230312021543.3060328-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5dd827e0