1. 14 Jun, 2023 6 commits
    • Ian Rogers's avatar
      tools api fs: More thread safety for global filesystem variables · 97d5f2e9
      Ian Rogers authored
      Multiple threads, such as with "perf top", may race to initialize a
      file system path like hugetlbfs. The racy initialization of the path
      leads to at least memory leaks. To avoid this initialize each fs for
      reading the mount point path with pthread_once.
      
      Mounting the file system may also be racy, so introduce a mutex over
      the function. This does mean that the path is being accessed with and
      without a mutex, which is inherently racy but hopefully benign,
      especially as there are fewer callers to fs__mount.
      
      Remove the fs__entries by directly using global variables, this was
      done as no argument like the index can be passed to the init once
      routine.
      
      Issue found and tested with "perf top" and address sanitizer.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230609224004.180988-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      97d5f2e9
    • Ian Rogers's avatar
      perf srcline: Make sentinel reading for binutils addr2line more robust · 8dc26b6f
      Ian Rogers authored
      The addr2line process is sent an address then multiple function,
      filename:line "records" are read. To detect the end of output a ',' is
      sent and for llvm-addr2line a ',' is then read back showing the end of
      addrline's output.
      
      For binutils addr2line the ',' translates to address 0 and we expect the
      bogus filename marker "??:0" (see filename_split) to be sent from
      addr2line.
      
      For some kernels address 0 may have a mapping and so a seemingly valid
      inline output is given and breaking the sentinel discovery:
      
        ```
        $ addr2line -e vmlinux -f -i
        ,
        __per_cpu_start
        ./arch/x86/kernel/cpu/common.c:1850
        ```
      
      To avoid this problem enable the address dumping for addr2line (the -a
      option). If an address of 0x0000000000000000 is read then this is the
      sentinel value working around the problem above.
      
      The filename_split still needs to check for "??:0" as bogus non-zero
      addresses also need handling.
      Reported-by: default avatarChangbin Du <changbin.du@huawei.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarChangbin Du <changbin.du@huawei.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: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230613034817.1356114-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8dc26b6f
    • Ian Rogers's avatar
      perf srcline: Make addr2line configuration failure more verbose · c7a0023a
      Ian Rogers authored
      To aid debugging why it fails. Also, combine the loops for reading a
      line for the llvm/binutils cases.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarChangbin Du <changbin.du@huawei.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: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230613034817.1356114-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c7a0023a
    • Adrian Hunter's avatar
      perf tests: Make x86 new instructions test optional at build time · d436373a
      Adrian Hunter authored
      The "x86 instruction decoder - new instructions" test takes up space but
      is only really useful to developers. Make it optional at build time.
      
      Add variable EXTRA_TESTS which must be defined in order to build perf
      with the test.
      
      Example:
      
        Before:
      
          $ make -C tools/perf clean >/dev/null
          $ make -C tools/perf >/dev/null
          Makefile.config:650: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
          Makefile.config:1149: libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev
            PERF_VERSION = 6.4.rc3.gd15b8c76
          $ readelf -SW tools/perf/perf | grep '\.rela.dyn\|.rodata\|\.data.rel.ro'
            [10] .rela.dyn         RELA            000000000002fcb0 02fcb0 0748b0 18   A  6   0  8
            [18] .rodata           PROGBITS        00000000002eb000 2eb000 6bac00 00   A  0   0 32
            [25] .data.rel.ro      PROGBITS        00000000009ea180 9e9180 04b540 00  WA  0   0 32
      
        After:
      
          $ make -C tools/perf clean >/dev/null
          $ make -C tools/perf >/dev/null
          Makefile.config:650: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
          Makefile.config:1154: libpfm4 not found, disables libpfm4 support. Please install libpfm4-dev
            PERF_VERSION = 6.4.rc3.g4ea9c1569ea4
          $ readelf -SW tools/perf/perf | grep '\.rela.dyn\|.rodata\|\.data.rel.ro'
            [10] .rela.dyn         RELA            000000000002f3c8 02f3c8 036d68 18   A  6   0  8
            [18] .rodata           PROGBITS        00000000002ac000 2ac000 68da80 00   A  0   0 32
            [25] .data.rel.ro      PROGBITS        000000000097d440 97c440 022280 00  WA  0   0 32
      
      Committer notes:
      
      Build with 'make EXTRA_TESTS=1 -C tools/perf O=/tmp/build/perf" and
      reproduced the ELF section size differences.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@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/683fea7c-f5e9-fa20-f96b-f6233ed5d2a7@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d436373a
    • Namhyung Kim's avatar
      perf dwarf-aux: Allow unnamed struct/union/enum · 7f911905
      Namhyung Kim authored
      It's possible some struct/union/enum type don't have type name.  Allow
      the empty name after "struct"/"union"/"enum" string rather than fail.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230612234102.3909116-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7f911905
    • Namhyung Kim's avatar
      perf dwarf-aux: Fix off-by-one in die_get_varname() · 3abfcfd8
      Namhyung Kim authored
      The die_get_varname() returns "(unknown_type)" string if it failed to
      find a type for the variable.  But it had a space before the opening
      parenthesis and it made the closing parenthesis cut off due to the
      off-by-one in the string length (14).
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Fixes: 88fd633c ("perf probe: No need to use formatting strbuf method")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230612234102.3909116-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3abfcfd8
  2. 13 Jun, 2023 2 commits
  3. 12 Jun, 2023 32 commits
    • Ian Rogers's avatar
      perf inject: Lazily allocate guest_event event_buf · 892d00fb
      Ian Rogers authored
      The event_buf is 64kb (PERF_SAMPLE_SIZE_MAX) and stack allocated in
      struct perf_inject. It is used for guest events that may not exist in
      a file. Make the array allocation lazy to cut down on the stack usage.
      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/20230527034324.2597593-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      892d00fb
    • Ian Rogers's avatar
      perf inject: Lazily allocate event_copy · d3944f0e
      Ian Rogers authored
      The event_copy is 64kb (PERF_SAMPLE_SIZE_MAX) and stack allocated in
      struct perf_inject. It is used for aux events that may not exist in a
      file. Make the array allocation lazy to cut down on the stack usage.
      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/20230527034324.2597593-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3944f0e
    • Ian Rogers's avatar
      perf script: Remove some large stack allocations · e590e46b
      Ian Rogers authored
      Some char buffers are stack allocated but in total they come to
      24kb. Avoid Wstack-usage warnings by moving the arrays to being
      dynamically allocated.
      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/20230527034324.2597593-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e590e46b
    • Ian Rogers's avatar
      perf sched: Avoid large stack allocations · 232418a0
      Ian Rogers authored
      Commit 5ded57ac ("perf inject: Remove static variables") moved
      static variables to local, however, in this case 3 MAX_CPUS (4096)
      sized arrays were moved onto the stack making the stack frame quite
      large. Avoid the stack usage by dynamically allocating the arrays.
      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/20230527034324.2597593-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      232418a0
    • Ian Rogers's avatar
      perf bench sched messaging: Free contexts on exit · e57d7393
      Ian Rogers authored
      Place sender and receiver contexts onto lists so that they may be
      freed on exit. Add missing pthread_attr_destroy. Fixes memory leaks
      reported by leak sanitizer.
      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: André Almeida <andrealmeid@igalia.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      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: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20230611233610.953456-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e57d7393
    • Ian Rogers's avatar
      perf bench futex: Avoid memory leaks from pthread_attr · 8351498d
      Ian Rogers authored
      Remove code sharing the pthread_attr_t and initialize/destroy
      pthread_attr_t when needed. This avoids the same attribute being set
      that leak sanitizer reports as a memory leak.
      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: André Almeida <andrealmeid@igalia.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      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: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20230611233610.953456-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8351498d
    • Ian Rogers's avatar
      perf bench epoll: Fix missing frees/puts on the exit path · e6deda2e
      Ian Rogers authored
      Issues detected by leak sanitizer.
      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: André Almeida <andrealmeid@igalia.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      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: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20230611233610.953456-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e6deda2e
    • Ian Rogers's avatar
      perf help: Ensure clean_cmds is called on all paths · 0f0d1354
      Ian Rogers authored
      Avoid potential memory leaks.
      
      Committer notes:
      
      This is right before calling exit(1), so just to clean up memory leak
      checker detection.
      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: André Almeida <andrealmeid@igalia.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      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: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20230611233610.953456-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f0d1354
    • Ian Rogers's avatar
      lib subcmd: Avoid memory leak in exclude_cmds · 657a3efe
      Ian Rogers authored
      exclude_cmds will shorten the cmds names array, before doing so free the
      removed entry.
      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: André Almeida <andrealmeid@igalia.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      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: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20230611233610.953456-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      657a3efe
    • James Clark's avatar
      perf cs-etm: Add exception level consistency check · d927ef50
      James Clark authored
      Assert that our own tracking of the exception level matches what
      OpenCSD provides. OpenCSD doesn't distinguish between EL0 and EL1 in the
      memory access callback so the extra tracking was required. But a rough
      assert can still be done.
      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: 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/20230612111403.100613-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d927ef50
    • James Clark's avatar
      perf cs-etm: Track exception level · 8d3031d3
      James Clark authored
      Currently we assume all trace belongs to the host machine so when
      the decoder should be looking at the guest kernel maps it can crash
      because it looks at the host ones instead.
      
      Avoid one scenario (guest kernel running at EL1) by assigning the
      default guest machine to this trace. For userspace trace it's still not
      possible to determine guest vs host, but the PIDs should help in this
      case.
      
      Committer notes:
      
      Fixed up conflict with:
      
        perf addr_location: Add init/exit/copy functions
      
      That was only on tmp.perf-tools-next.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      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: Mark Rutland <mark.rutland@arm.com>
      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/20230612111403.100613-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d3031d3
    • James Clark's avatar
      perf cs-etm: Make PID format accessible from struct cs_etm_auxtrace · 5414b532
      James Clark authored
      To avoid every user of PID format having to use their own static
      local variable, cache it on initialisation and change the accessor to
      take struct cs_etm_auxtrace.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      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: Mark Rutland <mark.rutland@arm.com>
      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/20230612111403.100613-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5414b532
    • James Clark's avatar
      perf cs-etm: Use previous thread for branch sample source IP · d67d8c87
      James Clark authored
      Branch samples currently use the IP of the previous packet as the from
      IP, and the IP of the current packet as the to IP. But it incorrectly
      uses the current thread. In some cases like a jump into a different
      exception level this will attribute to the incorrect process.
      
      Fix it by tracking the previous thread in the same way the previous
      packet is tracked.
      
      Committer notes:
      
      Resolved conflicts with:
      
        perf addr_location: Add init/exit/copy functions
        perf thread: Add accessor functions for thread
      Reviewed-by: default avatarMike Leach <mike.leach@linaro.org>
      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: 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: 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: http://lore.kernel.org/lkml/20230612111403.100613-3-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d67d8c87
    • James Clark's avatar
      perf cs-etm: Only track threads instead of PID and TIDs · 951ccccd
      James Clark authored
      PIDs and TIDs are already contained within the thread struct, so to
      avoid inconsistencies drop the extra members on the etm queue and only
      use the thread struct.
      
      At the same time stop using the 'unknown' thread. In a later commit
      we will be making samples from multiple machines so it will be better
      to use the idle thread of each machine rather than overlapping unknown
      threads. Using the idle thread is also better because kernel addresses
      with a previously unknown thread will now be assigned to a real kernel
      thread.
      
      Committer notes:
      
      Resolved conflicts with:
      
        perf addr_location: Add init/exit/copy functions
        perf thread: Add accessor functions for thread
        perf thread: Remove notion of dead threads
      
      That were present in tmp.perf-tools.next only.
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarMike Leach <mike.leach@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      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: http://lore.kernel.org/lkml/20230612111403.100613-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      951ccccd
    • James Clark's avatar
      perf map: Fix double 'struct map' reference free found with -DREFCNT_CHECKING=1 · 0d98a7af
      James Clark authored
      When quitting after running a 'perf report', the refcount checker finds
      some double frees. The issue is that map__put() is called on a function
      argument so it removes the refcount wrapper that someone else was using.
      
      Fix it by only calling map__put() on a reference that is owned by this
      function.
      
      Committer notes:
      
      Narrowed the map_ref scope as suggested by Ian, removed the symbol-elf
      part as it was already fixed by another patch, from Ian.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-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/20230612150424.198914-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0d98a7af
    • Arnaldo Carvalho de Melo's avatar
      perf srcline: Optimize comparision against SRCLINE_UNKNOWN · 922db21d
      Arnaldo Carvalho de Melo authored
      This is a string constant that gets returned and then strcmp() around,
      we can instead just do a pointer comparision.
      
      That requires a new global variable to comply with these warnings from
      some versions of clang and gcc:
      
        41    68.95 fedora:rawhide                : FAIL clang version 16.0.4 (Fedora 16.0.4-1.fc39)
          result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare]
                  if (start_line != SRCLINE_UNKNOWN &&
                                 ^  ~~~~~~~~~~~~~~~  41
      
      Ack comments:
      
      Agreed, the strcmps make me nervous as they won't distinguish heap from
      a global meaning we could end up with things like pointers to freed
      memory. The comparison with the global is always going to be same imo.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Link: https://lore.kernel.org/lkml/ZIcoJytUEz4UgQYR@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      922db21d
    • Ian Rogers's avatar
      perf hist: Fix srcline memory leak · 834631ee
      Ian Rogers authored
      srcline isn't freed if it is SRCLINE_UNKNOWN. Avoid strduping in this
      case as such strdups are redundant and leak memory.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-27-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      834631ee
    • Ian Rogers's avatar
      perf srcline: Change free_srcline to zfree_srcline · 625db36e
      Ian Rogers authored
      Make use after free more unlikely.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-26-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      625db36e
    • Ian Rogers's avatar
      perf callchain: Use pthread keys for tls callchain_cursor · 8ab12a20
      Ian Rogers authored
      Pthread keys are more portable than __thread and allow the association
      of a destructor with the key. Use the destructor to clean up TLS
      callchain cursors to aid understanding memory leaks.
      
      Committer notes:
      
      Had to fixup a series of unconverted places and also check for the
      return of get_tls_callchain_cursor() as it may fail and return NULL.
      
      In that unlikely case we now either print something to a file, if the
      caller was expecting to print a callchain, or return an error code to
      state that resolving the callchain isn't possible.
      
      In some cases this was made easier because thread__resolve_callchain()
      already can fail for other reasons, so this new one (cursor == NULL) can
      be added and the callers don't have to explicitely check for this new
      condition.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-25-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8ab12a20
    • Ian Rogers's avatar
      perf header: Avoid out-of-bounds read · d7ba60a4
      Ian Rogers authored
      intel-pt tests were failing:
      
        -- Test virtual LBR ---
        Linux
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.126 MB /tmp/perf-test-intel-pt-sh.FW57CXnCqQ/test-perf.data ]
        Failed with virtual lbr
        ...
        ```
      
        The root cause is an out-of-bounds read in header (where maxbrstack.py
        is from test_intel_pt.sh):
        ```
        $ perf --no-pager script --itrace=L -s maxbrstack.py
        =================================================================
        ==3907930==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020000095a8 at pc 0x563c26c840bb bp 0x7fff43582710 sp 0x7fff43582708
        READ of size 4 at 0x6020000095a8 thread T0
            #0 0x563c26c840ba in process_group_desc util/header.c:2847
            #1 0x563c26c8bc78 in perf_file_section__process util/header.c:4037
            #2 0x563c26c8aa9b in perf_header__process_sections util/header.c:3813
            #3 0x563c26c8d028 in perf_session__read_header util/header.c:4286
            #4 0x563c26cbab29 in perf_session__open util/session.c:113
            #5 0x563c26cbb3d0 in __perf_session__new util/session.c:221
            #6 0x563c26aacb14 in perf_session__new util/session.h:73
            #7 0x563c26acf7f1 in cmd_script tools/perf/builtin-script.c:4212
            #8 0x563c26bb58ff in run_builtin tools/perf/perf.c:323
            #9 0x563c26bb5e70 in handle_internal_command tools/perf/perf.c:377
            #10 0x563c26bb6238 in run_argv tools/perf/perf.c:421
            #11 0x563c26bb67a0 in main tools/perf/perf.c:537
            #12 0x7f34bde46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
            #13 0x7f34bde46244 in __libc_start_main_impl ../csu/libc-start.c:381
            #14 0x563c26a33390 in _start (/tmp/perf/perf+0x1eb390)
      
        0x6020000095a8 is located 8 bytes to the right of 16-byte region [0x602000009590,0x6020000095a0)
        allocated by thread T0 here:
            #0 0x7f34beeb83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
            #1 0x563c26c83df8 in process_group_desc util/header.c:2824
            #2 0x563c26c8bc78 in perf_file_section__process util/header.c:4037
            #3 0x563c26c8aa9b in perf_header__process_sections util/header.c:3813
            #4 0x563c26c8d028 in perf_session__read_header util/header.c:4286
            #5 0x563c26cbab29 in perf_session__open util/session.c:113
            #6 0x563c26cbb3d0 in __perf_session__new util/session.c:221
            #7 0x563c26aacb14 in perf_session__new util/session.h:73
            #8 0x563c26acf7f1 in cmd_script tools/perf/builtin-script.c:4212
            #9 0x563c26bb58ff in run_builtin tools/perf/perf.c:323
            #10 0x563c26bb5e70 in handle_internal_command tools/perf/perf.c:377
            #11 0x563c26bb6238 in run_argv tools/perf/perf.c:421
            #12 0x563c26bb67a0 in main tools/perf/perf.c:537
            #13 0x7f34bde46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
        ```
      
      Avoid the out-of-bounds read checking for the leader. Leave the 'nr'
      check intact as nr will be 0 or the counting down and evsel be a group
      member.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/lkml/20230608232823.4027869-24-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d7ba60a4
    • Ian Rogers's avatar
      perf top: Add exit routine for main thread · cddeeeda
      Ian Rogers authored
      Add exit_process_thread that reverses init_process_thread. This avoids
      leak sanitizer reporting memory leaks.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-23-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cddeeeda
    • Ian Rogers's avatar
      perf annotate: Fix parse_objdump_line memory leak · d3d53b2e
      Ian Rogers authored
      fileloc is used to hold a previous line, before overwriting it ensure
      the previous contents is freed. Free the storage once done in
      symbol__disassemble.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-22-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3d53b2e
    • Ian Rogers's avatar
      perf map/maps/thread: Changes to reference counting · bffb5b0c
      Ian Rogers authored
      Fix missed reference count gets and puts as detected with leak
      sanitizer and 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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-21-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bffb5b0c
    • Ian Rogers's avatar
      perf machine: Don't leak module maps · 1981da1f
      Ian Rogers authored
      machine__addnew_module_map requires a put on its result. Add this and
      narrow the scope of map to make the correctness more obvious. This
      leak was caught with leak sanitizer and the reference count checker.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-20-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1981da1f
    • Ian Rogers's avatar
      perf machine: Fix leak of kernel dso · 34b29bd6
      Ian Rogers authored
      The kernel dso may be found by searching dsos or allocating if not
      found. The allocation returns with a reference count of 2, once for
      the dsos list and once for the returned value. The list search has a
      reference count of 1, once for the dsos list. To make the reference
      counts consistent, increase the dsos list search reference count to 2
      with a dso__get, and do a put when the scope ends for either the
      allocated or found dso.
      
      This issue was found with leak sanitizer and 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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-19-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      34b29bd6
    • Ian Rogers's avatar
      perf maps: Fix overlapping memory leak · 814a6568
      Ian Rogers authored
      Add a missed free detected by leak sanitizer.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-18-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      814a6568
    • Ian Rogers's avatar
      perf symbol-elf: Correct holding a reference · fe8fec10
      Ian Rogers authored
      If a reference is held, don't put it as this will confuse 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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-17-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fe8fec10
    • Ian Rogers's avatar
      perf jit: Fix two thread leaks · 5cedd1e2
      Ian Rogers authored
      As reported by leak sanitizer with 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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-16-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5cedd1e2
    • Ian Rogers's avatar
      perf python: Avoid 2 leak sanitizer issues · 51cfe7a3
      Ian Rogers authored
      Leak sanitizer complains about the variable size bf allocation and
      store to bf if sized 0.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-15-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      51cfe7a3
    • Ian Rogers's avatar
      perf evlist: Free stats in all evlist destruction · ac873ac3
      Ian Rogers authored
      There is no evsel free stats, freeing in the evlist__delete ensures
      memory leaks are avoided. Issues detected with "perf stat report" and
      leak sanitizer, perf stat uses perf_session__delete to free the
      evlist. Add dummy symbol for python build.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-14-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ac873ac3
    • Ian Rogers's avatar
      perf intel-pt: Fix missed put and leak · 084770f5
      Ian Rogers authored
      Add missing put and free, detected with leak sanitizer.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      084770f5
    • Ian Rogers's avatar
      perf stat: Avoid evlist leak · 2b87be18
      Ian Rogers authored
      Free evlist before overwriting in "perf stat report" mode. Detected
      using leak sanitizer.
      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: Ali Saidi <alisaidi@amazon.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brian Robbins <brianrob@linux.microsoft.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.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: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Ye Xingchen <ye.xingchen@zte.com.cn>
      Cc: Yuan Can <yuancan@huawei.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230608232823.4027869-12-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2b87be18