OpenCloudOS-Kernel/tools/perf
Ian Rogers 42cd165b4c perf callchain: Fix stitch LBR memory leaks
[ Upstream commit 599c19397b17d197fc1184bbc950f163a292efc9 ]

The 'struct callchain_cursor_node' has a 'struct map_symbol' whose maps
and map members are reference counted. Ensure these values use a _get
routine to increment the reference counts and use map_symbol__exit() to
release the reference counts.

Do similar for 'struct thread's prev_lbr_cursor, but save the size of
the prev_lbr_cursor array so that it may be iterated.

Ensure that when stitch_nodes are placed on the free list the
map_symbols are exited.

Fix resolve_lbr_callchain_sample() by replacing list_replace_init() to
list_splice_init(), so the whole list is moved and nodes aren't leaked.

A reproduction of the memory leaks is possible with a leak sanitizer
build in the perf report command of:

  ```
  $ perf record -e cycles --call-graph lbr perf test -w thloop
  $ perf report --stitch-lbr
  ```

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Fixes: ff165628d7 ("perf callchain: Stitch LBR call stack")
Signed-off-by: Ian Rogers <irogers@google.com>
[ Basic tests after applying the patch, repeating the example above ]
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anne Macedo <retpolanne@posteo.net>
Cc: Changbin Du <changbin.du@huawei.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/20240808054644.1286065-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-10-10 11:57:41 +02:00
..
Documentation perf: script: add raw|disasm arguments to --insn-trace option 2024-06-27 13:49:14 +02:00
arch perf intel-pt: Fix exclude_guest setting 2024-08-03 08:53:53 +02:00
bench perf bench internals inject-build-id: Fix trap divide when collecting just one DSO 2024-06-12 11:12:26 +02:00
dlfilters perf dlfilter: Add a test for object_code() 2023-09-30 00:09:06 -07:00
include/perf perf dlfilter: Add al_cleanup() 2023-08-15 16:41:49 -03:00
jvmti
pmu-events perf stat: Do not fail on metrics on s390 z/VM systems 2024-06-12 11:12:15 +02:00
python
scripts perf scripts python gecko: Launch the profiler UI on the default browser with the appropriate URL 2023-08-24 14:41:49 -03:00
tests perf test: Make test_arm_callgraph_fp.sh more robust 2024-08-03 08:53:52 +02:00
trace perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
ui perf ui/browser/annotate: Use global annotation_options 2024-10-04 16:29:24 +02:00
util perf callchain: Fix stitch LBR memory leaks 2024-10-10 11:57:41 +02:00
.gitignore perf jevents: Run metric_test.py at compile-time 2023-02-03 17:11:39 -03:00
Build perf script: Fix Python support when no libtraceevent 2023-03-15 10:27:07 -03:00
CREDITS
MANIFEST tools lib traceevent: Remove libtraceevent 2022-12-14 11:16:12 -03:00
Makefile perf tools: Use "grep -E" instead of "egrep" 2022-12-14 15:28:19 -03:00
Makefile.config perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
Makefile.perf perf bpf: Clean up the generated/copied vmlinux.h 2024-03-26 18:19:45 -04:00
builtin-annotate.c perf ui/browser/annotate: Use global annotation_options 2024-10-04 16:29:24 +02:00
builtin-bench.c perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
builtin-buildid-cache.c
builtin-buildid-list.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-c2c.c perf callchain: Use pthread keys for tls callchain_cursor 2023-06-12 15:57:54 -03:00
builtin-config.c perf path: Make mkpath thread safe, remove 16384 bytes from .bss 2023-05-28 10:24:14 -03:00
builtin-daemon.c perf daemon: Fix file leak in daemon_session__control 2024-06-12 11:12:30 +02:00
builtin-data.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-diff.c perf diff: Replaces some ',' as separator with the more usual ';' 2023-07-20 11:43:45 -03:00
builtin-evlist.c perf util: Move input_name to util 2023-04-10 19:21:31 -03:00
builtin-ftrace.c perf tools fixes for v6.4: 2nd batch 2023-05-31 15:31:56 -03:00
builtin-help.c perf path: Make mkpath thread safe, remove 16384 bytes from .bss 2023-05-28 10:24:14 -03:00
builtin-inject.c perf inject: Fix leader sampling inserting additional samples 2024-10-04 16:29:23 +02:00
builtin-kallsyms.c perf symbol: Remove now unused symbol_conf.sort_by_name 2023-06-23 21:48:49 -07:00
builtin-kmem.c perf callchain: Use pthread keys for tls callchain_cursor 2023-06-12 15:57:54 -03:00
builtin-kvm.c perf evsel: Introduce evsel__name_is() method to check if the evsel name is equal to a given string 2023-04-24 14:28:11 -03:00
builtin-kwork.c perf kwork: Set ordered_events to true in 'struct perf_tool' 2023-11-20 11:59:25 +01:00
builtin-list.c perf list: Fix JSON segfault by setting the used skip_duplicate_pmus callback 2023-12-13 18:45:34 +01:00
builtin-lock.c tools/perf: Update call stack check in builtin-lock.c 2023-11-20 11:59:26 +01:00
builtin-mem.c perf mem: Free the allocated sort string, fixing a leak 2024-10-04 16:29:23 +02:00
builtin-probe.c perf probe: Dynamically allocate params memory 2023-05-28 10:24:02 -03:00
builtin-record.c perf record: Fix debug message placement for test consumption 2024-06-12 11:12:18 +02:00
builtin-report.c perf report: Fix --total-cycles --stdio output error 2024-10-04 16:29:24 +02:00
builtin-sched.c perf sched timehist: Fixed timestamp error when unable to confirm event sched_in time 2024-10-04 16:29:24 +02:00
builtin-script.c perf script: Show also errors for --insn-trace option 2024-06-27 13:49:14 +02:00
builtin-stat.c perf stat: Exit perf stat if parse groups fails 2024-01-25 15:35:51 -08:00
builtin-timechart.c perf addr_location: Add init/exit/copy functions 2023-06-12 15:57:53 -03:00
builtin-top.c perf ui/browser/annotate: Use global annotation_options 2024-10-04 16:29:24 +02:00
builtin-trace.c perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string 2023-08-18 16:33:28 -03:00
builtin-version.c Revert "perf build: Make BUILD_BPF_SKEL default, rename to NO_BPF_SKEL" 2023-05-06 18:07:37 -03:00
builtin.h perf usage: Move usage strings 2023-04-10 19:20:53 -03:00
check-headers.sh tools headers UAPI: Copy seccomp.h to be able to build 'perf bench' in older systems 2023-09-13 08:48:48 -03:00
command-list.txt perf help: Use HAVE_LIBTRACEEVENT to filter out unsupported commands 2023-01-02 11:51:53 -03:00
design.txt
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-02-08 10:38:10 -03:00
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
perf.h perf util: Move perf_guest/host declarations 2023-04-10 19:22:05 -03:00