perf bench: futex: Fix memory leak of perf_cpu_map__new
Subsystems (2)
PATCH 1/1 perf bench: futex: Fix memory leak of perf_cpu_map__new
ASan reports memory leaks while running:
$ sudo ./perf bench futex all
The leaks are caused by perf_cpu_map__new not being freed. This patch adds the missing perf_cpu_map__put since it calls cpu_map_delete implicitly.
Fixes 9c3516d1b850 ("libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions")
Signed-off-by Sohaib Mohamed <[email protected]>
--- tools/perf/bench/futex-lock-pi.c | 1 + tools/perf/bench/futex-requeue.c | 1 + tools/perf/bench/futex-wake-parallel.c | 1 + tools/perf/bench/futex-wake.c | 1 + 4 files changed, 4 insertions(+)
tools/perf/bench/futex-lock-pi.c +1 -0
@@ -233,6 +233,7 @@ int bench_futex_lock_pi(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; err:usage_with_options (bench_futex_lock_pi_usage, options);
tools/perf/bench/futex-requeue.c +1 -0
@@ -294,6 +294,7 @@ int bench_futex_requeue(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; err:usage_with_options (bench_futex_requeue_usage, options);
tools/perf/bench/futex-wake-parallel.c +1 -0
@@ -329,6 +329,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)print_summary ();free (blocked_worker); +perf_cpu_map__put (cpu); return ret; }#endif /* HAVE_PTHREAD_BARRIER */
tools/perf/bench/futex-wake.c +1 -0
@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; }
--
2.25.1
Em Fri, Nov 12, 2021 at 10:11:33PM +0200, Sohaib Mohamed escreveu:
Quoted 9 lines
ASan reports memory leaks while running:
$ sudo ./perf bench futex allThe leaks are caused by
perf_cpu_map__newnot being freed. This patch adds the missingperf_cpu_map__putsince it callscpu_map_deleteimplicitly.Fixes 9c3516d1b850 ("libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions")
Thanks, applied.
- Arnaldo
Quoted 57 lines
Signed-off-by Sohaib Mohamed <[email protected]>--- tools/perf/bench/futex-lock-pi.c | 1 + tools/perf/bench/futex-requeue.c | 1 + tools/perf/bench/futex-wake-parallel.c | 1 + tools/perf/bench/futex-wake.c | 1 + 4 files changed, 4 insertions(+)tools/perf/bench/futex-lock-pi.c +1
-0@@ -233,6 +233,7 @@ int bench_futex_lock_pi(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; err:usage_with_options (bench_futex_lock_pi_usage, options);tools/perf/bench/futex-requeue.c +1
-0@@ -294,6 +294,7 @@ int bench_futex_requeue(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; err:usage_with_options (bench_futex_requeue_usage, options);tools/perf/bench/futex-wake-parallel.c +1
-0@@ -329,6 +329,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)print_summary ();free (blocked_worker); +perf_cpu_map__put (cpu); return ret; }#endif /* HAVE_PTHREAD_BARRIER */ tools/perf/bench/futex-wake.c +1
-1@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)print_summary ();free (worker); +perf_cpu_map__put (cpu);return ret; } --2.25.1
Signature · 1 line
- Arnaldo