Skip to content

Commit 88e4823

Browse files
smalinuxacmel
authored andcommitted
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: 9c3516d ("libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions") Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: André Almeida <andrealmeid@collabora.com> Cc: Darren Hart <dvhart@infradead.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sohaib Mohamed <sohaib.amhmd@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lore.kernel.org/lkml/20211112201134.77892-1-sohaib.amhmd@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 3442b5e commit 88e4823

4 files changed

Lines changed: 4 additions & 0 deletions

File tree

tools/perf/bench/futex-lock-pi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
233233
print_summary();
234234

235235
free(worker);
236+
perf_cpu_map__put(cpu);
236237
return ret;
237238
err:
238239
usage_with_options(bench_futex_lock_pi_usage, options);

tools/perf/bench/futex-requeue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ int bench_futex_requeue(int argc, const char **argv)
294294
print_summary();
295295

296296
free(worker);
297+
perf_cpu_map__put(cpu);
297298
return ret;
298299
err:
299300
usage_with_options(bench_futex_requeue_usage, options);

tools/perf/bench/futex-wake-parallel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ int bench_futex_wake_parallel(int argc, const char **argv)
329329
print_summary();
330330

331331
free(blocked_worker);
332+
perf_cpu_map__put(cpu);
332333
return ret;
333334
}
334335
#endif /* HAVE_PTHREAD_BARRIER */

tools/perf/bench/futex-wake.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)
222222
print_summary();
223223

224224
free(worker);
225+
perf_cpu_map__put(cpu);
225226
return ret;
226227
}

0 commit comments

Comments
 (0)