Skip to contentSkip to conversation

perf bench: futex: Fix memory leak of perf_cpu_map__new

PATCH Applied Sohaib Mohamed 2 participants 2 messages Nov 12, 2021 – Nov 13, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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")
---
 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
index 5d1fe9c35807..137890f78e17 100644
@@ -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
index 97fe31fd3a23..f7a5ffebb940 100644
@@ -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
index e970e6b9ad53..0983f40b4b40 100644
@@ -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
index 77f058a47790..2226a475e782 100644
@@ -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

maintainer Applied
#1 lore raw

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 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")

Thanks, applied.

- Arnaldo

Quoted 57 lines
---
 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
index 5d1fe9c35807..137890f78e17 100644
@@ -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
index 97fe31fd3a23..f7a5ffebb940 100644
@@ -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
index e970e6b9ad53..0983f40b4b40 100644
@@ -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
index 77f058a47790..2226a475e782 100644
@@ -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