Skip to content

Commit

Permalink
perf bench futex: Fix memory leak of perf_cpu_map__new()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: André Almeida <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sohaib Mohamed <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
smalinux authored and acmel committed Nov 13, 2021
1 parent 3442b5e commit 88e4823
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/perf/bench/futex-lock-pi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tools/perf/bench/futex-requeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tools/perf/bench/futex-wake-parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
1 change: 1 addition & 0 deletions tools/perf/bench/futex-wake.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)
print_summary();

free(worker);
perf_cpu_map__put(cpu);
return ret;
}

0 comments on commit 88e4823

Please sign in to comment.