]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf bench futex: Fix memory leak of perf_cpu_map__new()
authorSohaib Mohamed <sohaib.amhmd@gmail.com>
Fri, 12 Nov 2021 20:11:33 +0000 (22:11 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 13 Nov 2021 21:11:51 +0000 (18:11 -0300)
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: 15eed1dabc409981 ("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>
tools/perf/bench/futex-lock-pi.c
tools/perf/bench/futex-requeue.c
tools/perf/bench/futex-wake-parallel.c
tools/perf/bench/futex-wake.c

index 5d1fe9c35807a436513e3c36bcf3ea5ae67dece9..137890f78e17ae2b75bebcb121ba805c7b98941b 100644 (file)
@@ -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);
index 97fe31fd3a236bc3ebd7934ad97028fd8c38718b..f7a5ffebb9408b5289c58fdebad226b648a3c3c8 100644 (file)
@@ -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);
index e970e6b9ad535a7b557bfb34fca8b5af64385415..0983f40b4b408d4c575a066b9966e52ea132b5aa 100644 (file)
@@ -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 */
index 77f058a4779034a52cc84d2dc27541fdaa6157c7..2226a475e782b62c74a1dc0d1135d4ceb1fd5d07 100644 (file)
@@ -222,5 +222,6 @@ int bench_futex_wake(int argc, const char **argv)
        print_summary();
 
        free(worker);
+       perf_cpu_map__put(cpu);
        return ret;
 }