1. 10 Oct, 2023 1 commit
  2. 05 Oct, 2023 6 commits
    • Kajol Jain's avatar
      tools/perf: Update call stack check in builtin-lock.c · d7c9ae8d
      Kajol Jain authored
      The perf test named "kernel lock contention analysis test"
      fails in powerpc system with below error:
      
        [command]# ./perf test 81 -vv
         81: kernel lock contention analysis test                            :
         --- start ---
        test child forked, pid 2140
        Testing perf lock record and perf lock contention
        Testing perf lock contention --use-bpf
        [Skip] No BPF support
        Testing perf lock record and perf lock contention at the same time
        Testing perf lock contention --threads
        Testing perf lock contention --lock-addr
        Testing perf lock contention --type-filter (w/ spinlock)
        Testing perf lock contention --lock-filter (w/ tasklist_lock)
        Testing perf lock contention --callstack-filter (w/ unix_stream)
        [Fail] Recorded result should have a lock from unix_stream:
        test child finished with -1
         ---- end ----
        kernel lock contention analysis test: FAILED!
      
      The test is failing because we get an address entry with 0 in
      perf lock samples for powerpc, and code for lock contention
      option "--callstack-filter" will not check further entries after
      address 0.
      
      Below are some of the samples from test generated perf.data file, which
      have 0 address in the 2nd entry of callstack:
       --------
      sched-messaging    3409 [001]  7152.904029: lock:contention_begin: 0xc00000c80904ef00 (flags=SPIN)
              c0000000001e926c __traceiter_contention_begin+0x6c ([kernel.kallsyms])
                             0 [unknown] ([unknown])
              c000000000f8a178 native_queued_spin_lock_slowpath+0x1f8 ([kernel.kallsyms])
              c000000000f89f44 _raw_spin_lock_irqsave+0x84 ([kernel.kallsyms])
              c0000000001d9fd0 prepare_to_wait+0x50 ([kernel.kallsyms])
              c000000000c80f50 sock_alloc_send_pskb+0x1b0 ([kernel.kallsyms])
              c000000000e82298 unix_stream_sendmsg+0x2b8 ([kernel.kallsyms])
              c000000000c78980 sock_sendmsg+0x80 ([kernel.kallsyms])
      
      sched-messaging    3408 [005]  7152.904036: lock:contention_begin: 0xc00000c80904ef00 (flags=SPIN)
              c0000000001e926c __traceiter_contention_begin+0x6c ([kernel.kallsyms])
                             0 [unknown] ([unknown])
              c000000000f8a178 native_queued_spin_lock_slowpath+0x1f8 ([kernel.kallsyms])
              c000000000f89f44 _raw_spin_lock_irqsave+0x84 ([kernel.kallsyms])
              c0000000001d9fd0 prepare_to_wait+0x50 ([kernel.kallsyms])
              c000000000c80f50 sock_alloc_send_pskb+0x1b0 ([kernel.kallsyms])
              c000000000e82298 unix_stream_sendmsg+0x2b8 ([kernel.kallsyms])
              c000000000c78980 sock_sendmsg+0x80 ([kernel.kallsyms])
       --------
      
      Based on commit 20002ded ("perf_counter: powerpc: Add callchain support"),
      incase of powerpc, the callchain saved by kernel always includes first
      three entries as the NIP (next instruction pointer), LR (link register), and
      the contents of LR save area in the second stack frame. In certain scenarios
      its possible to have invalid kernel instruction addresses in either of LR or the
      second stack frame's LR. In that case, kernel will store the address as zer0.
      Hence, its possible to have 2nd or 3rd callstack entry as 0.
      
      As per the current code in match_callstack_filter function, we skip the callstack
      check incase we get 0 address. And hence the test case is failing in powerpc.
      
      Fix this issue by updating the check in match_callstack_filter function,
      to not skip callstack check if the 2nd or 3rd entry have 0 address
      for powerpc.
      
      Result in powerpc after patch changes:
      
        [command]# ./perf test 81 -vv
         81: kernel lock contention analysis test                            :
         --- start ---
        test child forked, pid 4570
        Testing perf lock record and perf lock contention
        Testing perf lock contention --use-bpf
        [Skip] No BPF support
        Testing perf lock record and perf lock contention at the same time
        Testing perf lock contention --threads
        Testing perf lock contention --lock-addr
        Testing perf lock contention --type-filter (w/ spinlock)
        Testing perf lock contention --lock-filter (w/ tasklist_lock)
        [Skip] Could not find 'tasklist_lock'
        Testing perf lock contention --callstack-filter (w/ unix_stream)
        Testing perf lock contention --callstack-filter with task aggregation
        Testing perf lock contention CSV output
        [Skip] No BPF support
        test child finished with 0
         ---- end ----
        kernel lock contention analysis test: Ok
      
      Fixes: ebab2916 ("perf lock contention: Support filters for different aggregation")
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Tested-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: maddy@linux.ibm.com
      Cc: atrajeev@linux.vnet.ibm.com
      Link: https://lore.kernel.org/r/20231003092113.252380-1-kjain@linux.ibm.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      d7c9ae8d
    • Athira Rajeev's avatar
      tools/perf/tests: Fix object code reading to skip address that falls out of text section · 8f5b62a1
      Athira Rajeev authored
      The testcase "Object code reading" fails in somecases
      for "fs_something" sub test as below:
      
          Reading object code for memory address: 0xc008000007f0142c
          File is: /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko
          On file address is: 0x1114cc
          Objdump command is: objdump -z -d --start-address=0x11142c --stop-address=0x1114ac /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko
          objdump read too few bytes: 128
          test child finished with -1
      
      This can alo be reproduced when running perf record with
      workload that exercises fs_something() code. In the test
      setup, this is exercising xfs code since root is xfs.
      
          # perf record ./a.out
          # perf report -v |grep "xfs.ko"
            0.76% a.out /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko  0xc008000007de5efc B [k] xlog_cil_commit
            0.74% a.out  /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko  0xc008000007d5ae18 B [k] xfs_btree_key_offset
            0.74% a.out  /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko  0xc008000007e11fd4 B [k] 0x0000000000112074
      
      Here addr "0xc008000007e11fd4" is not resolved. since this is a
      kernel module, its offset is from the DSO. Xfs module is loaded
      at 0xc008000007d00000
      
         # cat /proc/modules | grep xfs
          xfs 2228224 3 - Live 0xc008000007d00000
      
      And size is 0x220000. So its loaded between  0xc008000007d00000
      and 0xc008000007f20000. From objdump, text section is:
          text 0010f7bc  0000000000000000 0000000000000000 000000a0 2**4
      
      Hence perf captured ip maps to 0x112074 which is:
      ( ip - start of module ) + a0
      
      This offset 0x112074 falls out .text section which is up to 0x10f7bc
      In this case for module, the address 0xc008000007e11fd4 is pointing
      to stub instructions. This address range represents the module stubs
      which is allocated on module load and hence is not part of DSO offset.
      
      To address this issue in "object code reading", skip the sample if
      address falls out of text section and is within the module end.
      Use the "text_end" member of "struct dso" to do this check.
      
      To address this issue in "perf report", exploring an option of
      having stubs range as part of the /proc/kallsyms, so that perf
      report can resolve addresses in stubs range
      
      However this patch uses text_end to skip the stub range for
      Object code reading testcase.
      Reported-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Tested-by: Disha Goel<disgoel@linux.ibm.com>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: maddy@linux.ibm.com
      Cc: disgoel@linux.vnet.ibm.com
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230928075213.84392-3-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      8f5b62a1
    • Athira Rajeev's avatar
      tools/perf: Add "is_kmod" to struct dso to check if it is kernel module · 6be5d828
      Athira Rajeev authored
      Update "struct dso" to include new member "is_kmod".
      This new field will determine if the file is a kernel
      module or not.
      
      To resolve the address from a sample, perf looks at the
      DSO maps. In case of address from a kernel module, there
      were some address found to be not resolved. This was
      observed while running perf test for "Object code reading".
      Though the ip falls beteen the start address of the loaded
      module (perf map->start ) and end address ( perf map->end),
      it was unresolved.
      
      This was happening because in some cases for kernel
      modules, address from sample points to stub instructions.
      To identify if the DSO is a kernel module, the new field
      "is_kmod" is added to "struct dso".
      Reported-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: kjain@linux.ibm.com
      Cc: maddy@linux.ibm.com
      Cc: disgoel@linux.vnet.ibm.com
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230928075213.84392-2-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      6be5d828
    • Athira Rajeev's avatar
      tools/perf: Add text_end to "struct dso" to save .text section size · 26a5262d
      Athira Rajeev authored
      Update "struct dso" to include new member "text_end".
      This new field will represent the offset for end of text
      section for a dso. For elf, this value is derived as:
      sh_size (Size of section in byes) + sh_offset (Section file
      offst) of the elf header for text.
      
      For bfd, this value is derived as:
      1. For PE file,
      section->size + ( section->vma - dso->text_offset)
      2. Other cases:
      section->filepos (file position) + section->size (size of
      section)
      
      To resolve the address from a sample, perf looks at the
      DSO maps. In case of address from a kernel module, there
      were some address found to be not resolved. This was
      observed while running perf test for "Object code reading".
      Though the ip falls beteen the start address of the loaded
      module (perf map->start ) and end address ( perf map->end),
      it was unresolved.
      
      Example:
      
          Reading object code for memory address: 0xc008000007f0142c
          File is: /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko
          On file address is: 0x1114cc
          Objdump command is: objdump -z -d --start-address=0x11142c --stop-address=0x1114ac /lib/modules/6.5.0-rc3+/kernel/fs/xfs/xfs.ko
          objdump read too few bytes: 128
          test child finished with -1
      
      Here, module is loaded at:
          # cat /proc/modules | grep xfs
          xfs 2228224 3 - Live 0xc008000007d00000
      
      From objdump for xfs module, text section is:
          text 0010f7bc  0000000000000000 0000000000000000 000000a0 2**4
      
      Here the offset for 0xc008000007f0142c ie  0x112074 falls out
      .text section which is up to 0x10f7bc.
      
      In this case for module, the address 0xc008000007e11fd4 is pointing
      to stub instructions. This address range represents the module stubs
      which is allocated on module load and hence is not part of DSO offset.
      
      To identify such  address, which falls out of text
      section and within module end, added the new field "text_end" to
      "struct dso".
      Reported-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: maddy@linux.ibm.com
      Cc: disgoel@linux.vnet.ibm.com
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230928075213.84392-1-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      26a5262d
    • Ian Rogers's avatar
      perf test: Avoid system wide when not privileged · 0ddce121
      Ian Rogers authored
      Switch the test program to sleep that makes more sense for system wide
      events. Only enable system wide when root or not paranoid. This avoids
      failures under some testing conditions like ARM cloud.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230930060206.2353141-1-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      0ddce121
    • Kuan-Wei Chiu's avatar
      perf hisi-ptt: Fix memory leak in lseek failure handling · be7a4caa
      Kuan-Wei Chiu authored
      In the previous code, there was a memory leak issue where the previously
      allocated memory was not freed upon a failed lseek operation. This patch
      addresses the problem by releasing the old memory before returning -errno
      in case of a lseek failure. This ensures that memory is properly managed
      and avoids potential memory leaks.
      Signed-off-by: default avatarKuan-Wei Chiu <visitorckw@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: yangyicong@hisilicon.com
      Cc: jonathan.cameron@huawei.com
      Link: https://lore.kernel.org/r/20230930072719.1267784-1-visitorckw@gmail.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      be7a4caa
  3. 30 Sep, 2023 2 commits
  4. 28 Sep, 2023 9 commits
  5. 27 Sep, 2023 11 commits
  6. 21 Sep, 2023 2 commits
  7. 20 Sep, 2023 1 commit
  8. 18 Sep, 2023 7 commits
    • Ian Rogers's avatar
      perf parse-events: Fix tracepoint name memory leak · ede72dca
      Ian Rogers authored
      Fuzzing found that an invalid tracepoint name would create a memory
      leak with an address sanitizer build:
      ```
      $ perf stat -e '*:o/' true
      event syntax error: '*:o/'
                             \___ parser error
      Run 'perf list' for a list of valid events
      
       Usage: perf stat [<options>] [<command>]
      
          -e, --event <event>   event selector. use 'perf list' to list available events
      
      =================================================================
      ==59380==ERROR: LeakSanitizer: detected memory leaks
      
      Direct leak of 4 byte(s) in 2 object(s) allocated from:
          #0 0x7f38ac07077b in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
          #1 0x55f2f41be73b in str util/parse-events.l:49
          #2 0x55f2f41d08e8 in parse_events_lex util/parse-events.l:338
          #3 0x55f2f41dc3b1 in parse_events_parse util/parse-events-bison.c:1464
          #4 0x55f2f410b8b3 in parse_events__scanner util/parse-events.c:1822
          #5 0x55f2f410d1b9 in __parse_events util/parse-events.c:2094
          #6 0x55f2f410e57f in parse_events_option util/parse-events.c:2279
          #7 0x55f2f4427b56 in get_value tools/lib/subcmd/parse-options.c:251
          #8 0x55f2f4428d98 in parse_short_opt tools/lib/subcmd/parse-options.c:351
          #9 0x55f2f4429d80 in parse_options_step tools/lib/subcmd/parse-options.c:539
          #10 0x55f2f442acb9 in parse_options_subcommand tools/lib/subcmd/parse-options.c:654
          #11 0x55f2f3ec99fc in cmd_stat tools/perf/builtin-stat.c:2501
          #12 0x55f2f4093289 in run_builtin tools/perf/perf.c:322
          #13 0x55f2f40937f5 in handle_internal_command tools/perf/perf.c:375
          #14 0x55f2f4093bbd in run_argv tools/perf/perf.c:419
          #15 0x55f2f409412b in main tools/perf/perf.c:535
      
      SUMMARY: AddressSanitizer: 4 byte(s) leaked in 2 allocation(s).
      ```
      Fix by adding the missing destructor.
      
      Fixes: 865582c3 ("perf tools: Adds the tracepoint name parsing support")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Link: https://lore.kernel.org/r/20230914164028.363220-1-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      ede72dca
    • Ian Rogers's avatar
      perf test: Detect off-cpu support from build options · b4f48f34
      Ian Rogers authored
      Use perf version to detect whether BPF skeletons were enabled in a
      build rather than a failing perf record.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Patrice Duroux <patrice.duroux@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230914211948.814999-6-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      b4f48f34
    • Ian Rogers's avatar
      perf test: Ensure EXTRA_TESTS is covered in build test · c2ac838e
      Ian Rogers authored
      Add to run variable.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Patrice Duroux <patrice.duroux@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230914211948.814999-5-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      c2ac838e
    • Ian Rogers's avatar
      perf test: Update build test for changed BPF skeleton defaults · c67c631d
      Ian Rogers authored
      Fix a target name and set BUILD_BPF_SKEL to 0 rather than 1.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Patrice Duroux <patrice.duroux@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230914211948.814999-4-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      c67c631d
    • Ian Rogers's avatar
      perf build: Default BUILD_BPF_SKEL, warn/disable for missing deps · 9925495d
      Ian Rogers authored
      LIBBPF is dependent on zlib so move the NO_ZLIB and feature check
      early to avoid statically building when zlib is disabled. This avoids
      a linkage failure with perf and static libbpf when zlib isn't
      specified.
      
      Move BUILD_BPF_SKEL logic to one place and if not defined set
      BUILD_BPF_SKEL to 1. Detect dependencies of building with BPF
      skeletons and warn/disable if the dependencies aren't present.
      
      Change Makefile.perf to contain BPF skeleton logic dependent on the
      Makefile.config result and refresh the comment about BUILD_BPF_SKEL.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Patrice Duroux <patrice.duroux@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230914211948.814999-3-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      9925495d
    • Ian Rogers's avatar
      perf version: Add status of bpf skeletons · 727e4314
      Ian Rogers authored
      Add status for BPF skeletons, to see if a build has them enabled:
      ```
      $ perf version --build-options
      perf version 6.6.rc1.g0381ae36d1a6
                       dwarf: [ OFF ]  # HAVE_DWARF_SUPPORT
          dwarf_getlocations: [ OFF ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
               syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_SUPPORT
                      libbfd: [ OFF ]  # HAVE_LIBBFD_SUPPORT
                  debuginfod: [ OFF ]  # HAVE_DEBUGINFOD_SUPPORT
                      libelf: [ OFF ]  # HAVE_LIBELF_SUPPORT
                     libnuma: [ OFF ]  # HAVE_LIBNUMA_SUPPORT
      numa_num_possible_cpus: [ OFF ]  # HAVE_LIBNUMA_SUPPORT
                     libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
                   libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
                    libslang: [ on  ]  # HAVE_SLANG_SUPPORT
                   libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
                   libunwind: [ OFF ]  # HAVE_LIBUNWIND_SUPPORT
          libdw-dwarf-unwind: [ OFF ]  # HAVE_DWARF_SUPPORT
                        zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                        lzma: [ on  ]  # HAVE_LZMA_SUPPORT
                   get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                         bpf: [ OFF ]  # HAVE_LIBBPF_SUPPORT
                         aio: [ on  ]  # HAVE_AIO_SUPPORT
                        zstd: [ on  ]  # HAVE_ZSTD_SUPPORT
                     libpfm4: [ on  ]  # HAVE_LIBPFM
               libtraceevent: [ on  ]  # HAVE_LIBTRACEEVENT
               bpf_skeletons: [ OFF ]  # HAVE_BPF_SKEL
      ```
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Patrice Duroux <patrice.duroux@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230914211948.814999-2-irogers@google.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      727e4314
    • Yang Li's avatar
      perf kwork top: Simplify bool conversion · 3ecf87b2
      Yang Li authored
      ./tools/perf/util/bpf_kwork_top.c:120:53-58: WARNING: conversion to bool not needed here
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230915063832.120274-1-yang.lee@linux.alibaba.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      3ecf87b2
  9. 17 Sep, 2023 1 commit
    • Thomas Richter's avatar
      perf jevent: fix core dump on software events on s390 · e47749f1
      Thomas Richter authored
      Running commands such as
       # ./perf stat -e cs -- true
       Segmentation fault (core dumped)
       # ./perf stat -e cpu-clock-- true
       Segmentation fault (core dumped)
       #
      
      dump core. This should not happen as these events are defined
      even when no hardware PMU is available.
      Debugging this reveals this call chain:
      
        perf_pmus__find_by_type(type=1)
        +--> pmu_read_sysfs(core_only=false)
             +--> perf_pmu__find2(dirfd=3, name=0x152a113 "software")
                  +--> perf_pmu__lookup(pmus=0x14f0568 <other_pmus>, dirfd=3,
                                        lookup_name=0x152a113 "software")
                       +--> perf_pmu__find_events_table (pmu=0x1532130)
      
      Now the pmu is "software" and it tries to find a proper table
      generated by the pmu-event generation process for s390:
      
       # cd pmu-events/
       # ./jevents.py  s390 all /root/linux/tools/perf/pmu-events/arch |\
              grep -E '^const struct pmu_table_entry'
       const struct pmu_table_entry pmu_events__cf_z10[] = {
       const struct pmu_table_entry pmu_events__cf_z13[] = {
       const struct pmu_table_entry pmu_metrics__cf_z13[] = {
       const struct pmu_table_entry pmu_events__cf_z14[] = {
       const struct pmu_table_entry pmu_metrics__cf_z14[] = {
       const struct pmu_table_entry pmu_events__cf_z15[] = {
       const struct pmu_table_entry pmu_metrics__cf_z15[] = {
       const struct pmu_table_entry pmu_events__cf_z16[] = {
       const struct pmu_table_entry pmu_metrics__cf_z16[] = {
       const struct pmu_table_entry pmu_events__cf_z196[] = {
       const struct pmu_table_entry pmu_events__cf_zec12[] = {
       const struct pmu_table_entry pmu_metrics__cf_zec12[] = {
       const struct pmu_table_entry pmu_events__test_soc_cpu[] = {
       const struct pmu_table_entry pmu_metrics__test_soc_cpu[] = {
       const struct pmu_table_entry pmu_events__test_soc_sys[] = {
       #
      
      However event "software" is not listed, as can be seen in the
      generated const struct pmu_events_map pmu_events_map[].
      So in function perf_pmu__find_events_table(), the variable
      table is initialized to NULL, but never set to a proper
      value. The function scans all generated &pmu_events_map[]
      tables, but no table matches, because the tables are
      s390 CPU Measurement unit specific:
      
        i = 0;
        for (;;) {
            const struct pmu_events_map *map = &pmu_events_map[i++];
            if (!map->arch)
                 break;
      
            --> the maps are there because the build generated them
      
                 if (!strcmp_cpuid_str(map->cpuid, cpuid)) {
                      table = &map->event_table;
                      break;
                 }
            --> Since no matching CPU string the table var remains 0x0
            }
            free(cpuid);
            if (!pmu)
                 return table;
      
            --> The pmu is "software" so it exists and no return
      
            --> and here perf dies because table is 0x0
            for (i = 0; i < table->num_pmus; i++) {
      	      ...
            }
            return NULL;
      
      Fix this and do not access the table variable. Instead return 0x0
      which is the same return code when the for-loop was not successful.
      
      Output after:
       # ./perf stat -e cs -- true
      
       Performance counter stats for 'true':
      
                       0      cs
      
             0.000853105 seconds time elapsed
      
             0.000061000 seconds user
             0.000827000 seconds sys
      
       # ./perf stat -e cpu-clock -- true
      
       Performance counter stats for 'true':
      
                    0.25 msec cpu-clock #    0.341 CPUs utilized
      
             0.000728383 seconds time elapsed
      
             0.000055000 seconds user
             0.000706000 seconds sys
      
       # ./perf stat -e cycles -- true
      
       Performance counter stats for 'true':
      
         <not supported>      cycles
      
             0.000767298 seconds time elapsed
      
             0.000055000 seconds user
             0.000739000 seconds sys
      
       #
      
      Fixes: 7c52f10c ("perf pmu: Cache JSON events table")
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: dengler@linux.ibm.com
      Cc: gor@linux.ibm.com
      Cc: hca@linux.ibm.com
      Cc: sumanthk@linux.ibm.com
      Cc: svens@linux.ibm.com
      Link: https://lore.kernel.org/r/20230913125157.2790375-1-tmricht@linux.ibm.comSigned-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      e47749f1