1. 06 May, 2023 2 commits
  2. 05 May, 2023 3 commits
    • Ian Rogers's avatar
      perf metrics: Fix SEGV with --for-each-cgroup · 6c73f819
      Ian Rogers authored
      Ensure the metric threshold is copied correctly or else a use of
      uninitialized memory happens.
      
      Fixes: d0a3052f ("perf metric: Compute and print threshold values")
      Reported-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230505204119.3443491-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6c73f819
    • Arnaldo Carvalho de Melo's avatar
      perf bpf skels: Stop using vmlinux.h generated from BTF, use subset of used structs + CO-RE · a8874665
      Arnaldo Carvalho de Melo authored
      Linus reported a build break due to using a vmlinux without a BTF elf
      section to generate the vmlinux.h header with bpftool for use in the BPF
      tools in tools/perf/util/bpf_skel/*.bpf.c.
      
      Instead add a vmlinux.h file with the structs needed with the fields the
      tools need, marking the structs with __attribute__((preserve_access_index)),
      so that libbpf's CO-RE code can fixup the struct field offsets.
      
      In some cases the vmlinux.h file that was being generated by bpftool
      from the kernel BTF information was not needed at all, just including
      linux/bpf.h, sometimes linux/perf_event.h was enough as non-UAPI
      types were not being used.
      
      To keep te patch small, include those UAPI headers from the trimmed down
      vmlinux.h file, that then provides the tools with just the structs and
      the subset of its fields needed for them.
      
      Testing it:
      
        # perf lock contention -b find / > /dev/null
        ^C contended   total wait     max wait     avg wait         type   caller
      
                 7     53.59 us     10.86 us      7.66 us     rwlock:R   start_this_handle+0xa0
                 2     30.35 us     21.99 us     15.17 us	 rwsem:R   iterate_dir+0x52
                 1	  9.04 us      9.04 us      9.04 us     rwlock:W   start_this_handle+0x291
                 1	  8.73 us      8.73 us      8.73 us     spinlock   raw_spin_rq_lock_nested+0x1e
        #
        # perf lock contention -abl find / > /dev/null
        ^C contended   total wait     max wait     avg wait            address   symbol
      
                 1    262.96 ms    262.96 ms    262.96 ms   ffff8e67502d0170    (mutex)
                12    244.24 us     39.91 us     20.35 us   ffff8e6af56f8070   mmap_lock (rwsem)
                 7     30.28 us      6.85 us      4.33 us   ffff8e6c865f1d40   rq_lock (spinlock)
                 3	  7.42 us      4.03 us      2.47 us   ffff8e6c864b1d40   rq_lock (spinlock)
                 2	  3.72 us      2.19 us      1.86 us   ffff8e6c86571d40   rq_lock (spinlock)
                 1	  2.42 us      2.42 us      2.42 us   ffff8e6c86471d40   rq_lock (spinlock)
                 4	  2.11 us	559 ns       527 ns   ffffffff9a146c80   rcu_state (spinlock)
                 3	  1.45 us	818 ns       482 ns   ffff8e674ae8384c    (rwlock)
                 1	   870 ns	870 ns       870 ns   ffff8e68456ee060    (rwlock)
                 1	   663 ns	663 ns       663 ns   ffff8e6c864f1d40   rq_lock (spinlock)
                 1	   573 ns	573 ns       573 ns   ffff8e6c86531d40   rq_lock (spinlock)
                 1	   472 ns	472 ns       472 ns   ffff8e6c86431740    (spinlock)
                 1	   397 ns	397 ns       397 ns   ffff8e67413a4f04    (spinlock)
        #
        # perf test offcpu
        95: perf record offcpu profiling tests                              : Ok
        #
        # perf kwork latency --use-bpf
        Starting trace, Hit <Ctrl+C> to stop and report
        ^C
          Kwork Name                     | Cpu  | Avg delay     | Count     | Max delay     | Max delay start     | Max delay end	  |
         --------------------------------------------------------------------------------------------------------------------------------
          (w)flush_memcg_stats_dwork     | 0000 |   1056.212 ms |         2 |   2112.345 ms |     550113.229573 s |     550115.341919 s |
          (w)toggle_allocation_gate	   | 0000 |     10.144 ms |        62 |    416.389 ms |     550113.453518 s |     550113.869907 s |
          (w)0xffff8e6748e28080          | 0002 |	 0.623 ms |         1 |      0.623 ms |     550110.989841 s |     550110.990464 s |
          (w)vmstat_shepherd             | 0000 |	 0.586 ms |        10 |      2.828 ms |     550111.971536 s |     550111.974364 s |
          (w)vmstat_update               | 0007 |	 0.363 ms |         5 |      1.634 ms |     550113.222520 s |     550113.224154 s |
          (w)vmstat_update               | 0000 |	 0.324 ms |        10 |      2.827 ms |     550111.971526 s |     550111.974354 s |
          (w)0xffff8e674c5f4a58          | 0002 |	 0.102 ms |         5 |      0.134 ms |     550110.989839 s |     550110.989972 s |
          (w)psi_avgs_work               | 0001 |	 0.086 ms |         3 |      0.107 ms |     550114.957852 s |     550114.957959 s |
          (w)psi_avgs_work               | 0000 |	 0.079 ms |         5 |      0.100 ms |     550118.605668 s |     550118.605768 s |
          (w)kfree_rcu_monitor           | 0006 |	 0.079 ms |         1 |      0.079 ms |     550110.925821 s |     550110.925900 s |
          (w)psi_avgs_work               | 0004 |	 0.079 ms |         1 |      0.079 ms |     550109.581835 s |     550109.581914 s |
          (w)psi_avgs_work               | 0001 |	 0.078 ms |         1 |      0.078 ms |     550109.197809 s |     550109.197887 s |
          (w)psi_avgs_work               | 0002 |	 0.077 ms |         5 |      0.086 ms |     550110.669819 s |     550110.669905 s |
        <SNIP>
        # strace -e bpf -o perf-stat-bpf-counters.output perf stat -e cycles --bpf-counters sleep 1
      
         Performance counter stats for 'sleep 1':
      
                 6,197,983	  cycles
      
               1.003922848 seconds time elapsed
      
               0.000000000 seconds user
               0.002032000 seconds sys
      
        # head -7 perf-stat-bpf-counters.output
        bpf(BPF_OBJ_GET, {pathname="/sys/fs/bpf/perf_attr_map", bpf_fd=0, file_flags=0}, 16) = 3
        bpf(BPF_OBJ_GET_INFO_BY_FD, {info={bpf_fd=3, info_len=88, info=0x7ffcead64990}}, 16) = 0
        bpf(BPF_MAP_LOOKUP_ELEM, {map_fd=3, key=0x24129e0, value=0x7ffcead65a48, flags=BPF_ANY}, 32) = 0
        bpf(BPF_LINK_GET_FD_BY_ID, {link_id=1252}, 12) = -1 ENOENT (No such file or directory)
        bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffcead65780, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0,
      +func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0}, 116) = 4
        bpf(BPF_PROG_LOAD, {prog_type=BPF_PROG_TYPE_SOCKET_FILTER, insn_cnt=2, insns=0x7ffcead65920, license="GPL", log_level=0, log_size=0, log_buf=NULL, kern_version=KERNEL_VERSION(0, 0, 0), prog_flags=0, prog_name="", prog_ifindex=0, expected_attach_type=BPF_CGROUP_INET_INGRESS, prog_btf_fd=0, func_info_rec_size=0,
      +func_info=NULL, func_info_cnt=0, line_info_rec_size=0, line_info=NULL, line_info_cnt=0, attach_btf_id=0, attach_prog_fd=0, fd_array=NULL}, 128) = 4
        bpf(BPF_BTF_LOAD, {btf="\237\353\1\0\30\0\0\0\0\0\0\0\20\0\0\0\20\0\0\0\5\0\0\0\1\0\0\0\0\0\0\1"..., btf_log_buf=NULL, btf_size=45, btf_log_size=0, btf_log_level=0}, 28) = 4
        #
      Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Suggested-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarSong Liu <song@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Co-developed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Link: https://lore.kernel.org/lkml/ZFU1PJrn8YtHIqno@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a8874665
    • Dmitrii Dolgov's avatar
      perf stat: Separate bperf from bpf_profiler · ecc68ee2
      Dmitrii Dolgov authored
      It seems that perf stat -b <prog id> doesn't produce any results:
      
          $ perf stat -e cycles -b 4 -I 10000 -vvv
          Control descriptor is not initialized
          cycles: 0 0 0
                      time        counts unit      events
      	10.007641640    <not supported>      cycles
      
      Looks like this happens because fentry/fexit progs are getting loaded, but the
      corresponding perf event is not enabled and not added into the events bpf map.
      I think there is some mixing up between two type of bpf support, one for bperf
      and one for bpf_profiler. Both are identified via evsel__is_bpf, based on which
      perf events are enabled, but for the latter (bpf_profiler) a perf event is
      required. Using evsel__is_bperf to check only bperf produces expected results:
      
          $ perf stat -e cycles -b 4 -I 10000 -vvv
          Control descriptor is not initialized
          ------------------------------------------------------------
          perf_event_attr:
            size                             136
            sample_type                      IDENTIFIER
            read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
            disabled                         1
            exclude_guest                    1
          ------------------------------------------------------------
          sys_perf_event_open: pid -1  cpu 0  group_fd -1  flags 0x8 = 3
          ------------------------------------------------------------
          [...perf_event_attr for other CPUs...]
          ------------------------------------------------------------
          cycles: 309426 169009 169009
      		time             counts unit events
      	10.010091271             309426      cycles
      
      The final numbers correspond (at least in the level of magnitude) to the
      same metric obtained via bpftool.
      
      Fixes: 112cb561 ("perf stat: Introduce config stat.bpf-counter-events")
      Reviewed-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarDmitrii Dolgov <9erthalion6@gmail.com>
      Tested-by: default avatarSong Liu <song@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <song@kernel.org>
      Link: https://lore.kernel.org/r/20230412182316.11628-1-9erthalion6@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ecc68ee2
  3. 03 May, 2023 2 commits
    • Thomas Richter's avatar
      perf test record+probe_libc_inet_pton: Fix call chain match on x86_64 · 1f85d016
      Thomas Richter authored
      The test case probe libc's inet_pton & backtrace it with ping fails with
      Fedora 38 on x86_64.
      
      Function getaddrinfo() does not show up in the call chain anymore:
      
        # ./perf script
        ping  1803 [000] 728.567146: probe_libc:inet_pton: (7f5275afc840)
                  133840 __GI___inet_pton+0x0 (/usr/lib64/libc.so.6)
                   27b4a __libc_start_call_main+0x7a (/usr/lib64/libc.so.6)
                   27c0b __libc_start_main@@GLIBC_2.34+0x8b (/usr/lib64/libc.so.6)
      
        ping  1803 [000]   728.567184: probe_libc:inet_pton: (7f5275afc840)
                  133840 __GI___inet_pton+0x0 (/usr/lib64/libc.so.6)
                    493e main+0xcde (/usr/bin/ping)
                   27b4a __libc_start_call_main+0x7a (/usr/lib64/libc.so.6)
      
        #
      
      which causes the test case to fail. Remove function getaddrinfo()
      from list of expected functions.
      
      Output before:
      
        # ./perf test 'libc'
        91: probe libc's inet_pton & backtrace it with ping    : FAILED!
        #
      
      Output after:
      
        # ./perf test 'libc'
        91: probe libc's inet_pton & backtrace it with ping    : Ok
        #
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230503081255.3372986-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f85d016
    • Thomas Richter's avatar
      perf test record+probe_libc_inet_pton: Fix call chain match on s390 · 311693ce
      Thomas Richter authored
      With Fedora 38 the perf test 86 probe libc's inet_pton fails on s390.
      The call chain of the ping command changed.  The functions
      text_to_binary_address() and gaih_inet() do not show up in the call
      chain anymore.
      
      Output before:
      
        # ./perf test -v 86
        86: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 541050
        fgrep: warning: fgrep is obsolescent; using grep -F
        fgrep: warning: fgrep is obsolescent; using grep -F
        BFD: DWARF error: could not find variable specification at offset 0x22011
        ...
      
        ping 541078 [002] 348826.679581: probe_libc:inet_pton_1: (3ffad84b940)
        14b940 __GI___inet_pton+0x0 (/usr/lib64/libc.so.6)
        10e9c3 __GI_getaddrinfo+0xeb3 (inlined)
        4397 main+0x737 (/usr/bin/ping)
         FAIL: expected backtrace entry "gaih_inet.*\+0x[[:xdigit:]]\
                +[[:space:]]\(/usr/lib64/libc.so.6|inlined\)$"
                got "4397 main+0x737 (/usr/bin/ping)"
        test child finished with -1
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: FAILED!
        #
      
      Output after:
      
        # ./perf test -v 86
        86: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 541098
        fgrep: warning: fgrep is obsolescent; using grep -F
        fgrep: warning: fgrep is obsolescent; using grep -F
        BFD: DWARF error: could not find variable specification at offset 0x309d1
        ...
      
        ping 541126 [006] 349309.099067: probe_libc:inet_pton_1: (3ffb7f4b940)
        14b940 __GI___inet_pton+0x0 (/usr/lib64/libc.so.6)
        10e9c3 __GI_getaddrinfo+0xeb3 (inlined)
        4397 main+0x737 (/usr/bin/ping)
        test child finished with 0
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: Ok
        #
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230503081134.3372415-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      311693ce
  4. 02 May, 2023 11 commits
  5. 29 Apr, 2023 2 commits
    • Ian Rogers's avatar
      perf stat: Disable TopdownL1 on hybrid · 06bff3d9
      Ian Rogers authored
      Bugs with event parsing, event grouping and metrics causes the
      TopdownL1 metricgroup to crash the perf command. Temporarily disable
      the group if no events/metrics are spcecified.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ahmad Yasin <ahmad.yasin@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Edward Baker <edward.baker@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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Samantha Alt <samantha.alt@intel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Weilin Wang <weilin.wang@intel.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20230428073809.1803624-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      06bff3d9
    • Ian Rogers's avatar
      perf stat: Avoid SEGV on counter->name · 0463ca3d
      Ian Rogers authored
      Switch to use evsel__name() that doesn't return NULL for hardware and
      similar events.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ahmad Yasin <ahmad.yasin@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Edward Baker <edward.baker@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: Kang Minchul <tegongkang@gmail.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Samantha Alt <samantha.alt@intel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Weilin Wang <weilin.wang@intel.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20230426070050.1315519-8-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0463ca3d
  6. 24 Apr, 2023 8 commits
    • James Clark's avatar
      perf cs-etm: Add separate decode paths for timeless and per-thread modes · d1efa4a0
      James Clark authored
      Timeless and per-thread are orthogonal concepts that are currently
      treated as if they are the same (per-thread == timeless). This breaks
      when you modify the command line or itrace options to something that the
      current logic doesn't expect.
      
      For example:
      
        # Force timeless with Z
        --itrace=Zi10i
      
        # Or inconsistent record options
        -e cs_etm/timestamp=1/ --per-thread
      
      Adding Z for decoding in per-cpu mode is particularly bad because in
      per-thread mode trace channel IDs are discarded and all assumed to be 0,
      which would mix trace from different CPUs in per-cpu mode.
      
      Although the results might not be perfect in all scenarios, if the user
      requests no timestamps, it should still be possible to decode in either
      mode. Especially if the relative times of samples in different processes
      aren't interesting, quite a bit of space can be saved by turning off
      timestamps in per-cpu mode.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-8-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d1efa4a0
    • James Clark's avatar
      perf cs-etm: Use bool type for boolean values · 1764ce06
      James Clark authored
      Using u8 for boolean values makes the code a bit more difficult to read
      so be more explicit by using bool.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-7-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1764ce06
    • James Clark's avatar
      perf cs-etm: Allow user to override timestamp and contextid settings · 7bfc1544
      James Clark authored
      Timestamps and context tracking are automatically enabled in per-core
      mode and it's impossible to override this. Use the new utility function
      to set them conditionally.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7bfc1544
    • James Clark's avatar
      perf cs-etm: Validate options after applying them · 35c51f83
      James Clark authored
      Currently the cs_etm_set_option() function both validates and applies
      the config options. Because it's only called when they are added
      automatically, there are some paths where the user can apply the option
      on the command line and skip the validation. By moving it to the end it
      covers both cases.
      
      Also, options don't need to be re-applied anyway, Perf handles parsing
      and applying the config terms automatically.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      35c51f83
    • James Clark's avatar
      perf cs-etm: Don't test full_auxtrace because it's always set · 3963d84b
      James Clark authored
      There is no path in cs-etm where this isn't true so it doesn't need to
      be tested. Also re-order the beginning of cs_etm_recording_options() so
      that nothing is done until the early exit is passed.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3963d84b
    • James Clark's avatar
      perf tools: Add util function for overriding user set config values · 6593f019
      James Clark authored
      There is some duplicated code to only override config values if they
      haven't already been set by the user so make a util function for this.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Denis Nikitin <denik@google.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: Leo Yan <leo.yan@linaro.org>
      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: Yang Shi <shy828301@gmail.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230424134748.228137-3-james.clark@arm.com
      [ Moved evsel__set_config_if_unset() to util/pmu.c to avoid dragging stuff into the python binding ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6593f019
    • James Clark's avatar
      perf cs-etm: Fix timeless decode mode detection · 449067f3
      James Clark authored
      In this context, timeless refers to the trace data rather than the perf
      event data. But when detecting whether there are timestamps in the trace
      data or not, the presence of a timestamp flag on any perf event is used.
      
      Since commit f42c0ce5 ("perf record: Always get text_poke events
      with --kcore option") timestamps were added to a tracking event when
      --kcore is used which breaks this detection mechanism. Fix it by
      detecting if trace timestamps exist by looking at the ETM config flags.
      This would have always been a more accurate way of doing it anyway.
      
      This fixes the following error message when using --kcore with
      Coresight:
      
        $ perf record --kcore -e cs_etm// --per-thread
        $ perf report
        The perf.data/data data has no samples!
      
      Fixes: f42c0ce5 ("perf record: Always get text_poke events with --kcore option")
      Reported-by: default avatarYang Shi <shy828301@gmail.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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: Leo Yan <leo.yan@linaro.org>
      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: denik@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/lkml/CAHbLzkrJQTrYBtPkf=jf3OpQ-yBcJe7XkvQstX9j2frz4WF-SQ@mail.gmail.com/
      Link: https://lore.kernel.org/r/20230424134748.228137-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      449067f3
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Introduce evsel__name_is() method to check if the evsel name is equal to a given string · ce1d3bc2
      Arnaldo Carvalho de Melo authored
      This makes the logic a bit clear by avoiding the !strcmp() pattern and
      also a way to intercept the pointer if we need to do extra validation on
      it or to do lazy setting of evsel->name via evsel__name(evsel).
      Reviewed-by: default avatar"Liang, Kan" <kan.liang@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZEGLM8VehJbS0gP2@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce1d3bc2
  7. 20 Apr, 2023 2 commits
    • Ian Rogers's avatar
      libperf rc_check: Enable implicitly with sanitizers · 9be6ab18
      Ian Rogers authored
      If using leak sanitizer then implicitly enable reference count checking.
      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: 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>
      Link: https://lore.kernel.org/r/20230420171812.561603-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9be6ab18
    • Ian Rogers's avatar
      perf test: Fix maps use after put · edd4cab2
      Ian Rogers authored
      Fix a use after put reference count issue. maps is copied from leader,
      but the leader is put on line 79 and then maps is used to read the
      reference count below - so a use after put, with the put of maps
      happening within thread__put. Fix by reversing the order of puts so
      that the leader is put last.
      
      To explain the reference count checker, I wrote this up as a little
      example here:
      https://perf.wiki.kernel.org/index.php/Reference_Count_Checking
      
      Note, the bug was introduced by the committer and wasn't present in
      the original reference count patch set.
      
      Committer notes:
      
      Yes, the bug predated your patch and is detected by the reference count
      checking you contributed.
      
      This was just part of splitting up your series into smaller chunks, in
      this case either we fix the problem detected while developing this
      reference counting infrastructure before the patch introducing REFCNT_CHECKING
      or fix it later after the merged infrastructure, when built with
      EXTRA_CFLAGS="-DREFCNT_CHECKING=1" detects it when running 'perf test', which
      is what this patch does.
      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: Jiri Olsa <jolsa@kernel.org>
      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/20230420030430.489243-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edd4cab2
  8. 19 Apr, 2023 9 commits
  9. 18 Apr, 2023 1 commit
    • James Clark's avatar
      perf cs-etm: Fix segfault in dso lookup · b550bc90
      James Clark authored
      map__dso() is called before thread__find_map() which always results in a
      null pointer dereference. Fix it by finding first, then checking if it
      exists.
      
      Fixes: 63df0e4b ("perf map: Add accessor for dso")
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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: Leo Yan <leo.yan@linaro.org>
      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/20230418141203.673465-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b550bc90