Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755404AbbLJIQr (ORCPT ); Thu, 10 Dec 2015 03:16:47 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55093 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581AbbLJIQo (ORCPT ); Thu, 10 Dec 2015 03:16:44 -0500 Date: Thu, 10 Dec 2015 00:16:24 -0800 From: tip-bot for Masami Hiramatsu Message-ID: Cc: hpa@zytor.com, mingo@kernel.org, jolsa@redhat.com, adrian.hunter@intel.com, acme@redhat.com, a.p.zijlstra@chello.nl, namhyung@kernel.org, linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de Reply-To: tglx@linutronix.de, masami.hiramatsu.pt@hitachi.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, acme@redhat.com, a.p.zijlstra@chello.nl, mingo@kernel.org, jolsa@redhat.com, adrian.hunter@intel.com, hpa@zytor.com In-Reply-To: <20151209021127.10245.93697.stgit@localhost.localdomain> References: <20151209021127.10245.93697.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Fix cmd_stat to release cpu_map Git-Commit-ID: 544c2ae7b1a794ad0bc5ec24d832ab5658d5aef6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2612 Lines: 75 Commit-ID: 544c2ae7b1a794ad0bc5ec24d832ab5658d5aef6 Gitweb: http://git.kernel.org/tip/544c2ae7b1a794ad0bc5ec24d832ab5658d5aef6 Author: Masami Hiramatsu AuthorDate: Wed, 9 Dec 2015 11:11:27 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 9 Dec 2015 13:41:59 -0300 perf stat: Fix cmd_stat to release cpu_map Fix cmd_stat() to release cpu_map objects (aggr_map and cpus_aggr_map) afterwards. refcnt debugger shows that the cmd_stat initializes cpu_map but not puts it. ---- # ./perf stat -v ls .... REFCNT: BUG: Unreclaimed objects found. ==== [0] ==== Unreclaimed cpu_map@0x29339c0 Refcount +1 => 1 at ./perf(cpu_map__empty_new+0x6d) [0x4e64bd] ./perf(cmd_stat+0x5fe) [0x43594e] ./perf() [0x47b785] ./perf(main+0x617) [0x422587] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2dff420af5] ./perf() [0x4226fd] REFCNT: Total 1 objects are not reclaimed. "cpu_map" leaks 1 objects ---- Signed-off-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20151209021127.10245.93697.stgit@localhost.localdomain [ Remove NULL checks before calling the put operation, it checks it already ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e74712d..25a95f4 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1094,6 +1094,14 @@ static int perf_stat_init_aggr_mode(void) return cpus_aggr_map ? 0 : -ENOMEM; } +static void perf_stat__exit_aggr_mode(void) +{ + cpu_map__put(aggr_map); + cpu_map__put(cpus_aggr_map); + aggr_map = NULL; + cpus_aggr_map = NULL; +} + /* * Add default attributes, if there were no attributes specified or * if -d/--detailed, -d -d or -d -d -d is used: @@ -1442,6 +1450,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused) if (!forever && status != -1 && !interval) print_counters(NULL, argc, argv); + perf_stat__exit_aggr_mode(); perf_evlist__free_stats(evsel_list); out: perf_evlist__delete(evsel_list); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/