Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbbKWQLk (ORCPT ); Mon, 23 Nov 2015 11:11:40 -0500 Received: from terminus.zytor.com ([198.137.202.10]:43927 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751200AbbKWQLh (ORCPT ); Mon, 23 Nov 2015 11:11:37 -0500 Date: Mon, 23 Nov 2015 08:11:10 -0800 From: tip-bot for Masami Hiramatsu Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, jolsa@redhat.com, adrian.hunter@intel.com, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, acme@redhat.com, namhyung@kernel.org, mingo@kernel.org Reply-To: mingo@kernel.org, namhyung@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, a.p.zijlstra@chello.nl, jolsa@redhat.com, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, tglx@linutronix.de In-Reply-To: <20151118064022.30709.3897.stgit@localhost.localdomain> References: <20151118064022.30709.3897.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf machine: Fix machine__destroy_kernel_maps to drop vmlinux_maps references Git-Commit-ID: e96e4078e9a5ea150b3ad9a296440a7976439e4a 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: 3178 Lines: 84 Commit-ID: e96e4078e9a5ea150b3ad9a296440a7976439e4a Gitweb: http://git.kernel.org/tip/e96e4078e9a5ea150b3ad9a296440a7976439e4a Author: Masami Hiramatsu AuthorDate: Wed, 18 Nov 2015 15:40:22 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 19 Nov 2015 13:19:18 -0300 perf machine: Fix machine__destroy_kernel_maps to drop vmlinux_maps references Fix machine__destroy_kernel_maps() to drop vmlinux_maps references before filling it with NULL. Refcnt debugger shows ==== [1] ==== Unreclaimed map: 0x36b1070 Refcount +1 => 1 at ./perf(map__new2+0xb5) [0x4bdec5] ./perf(machine__create_kernel_maps+0x72) [0x4bb152] ./perf(machine__new_host+0xfa) [0x4bb41a] ./perf(init_probe_symbol_maps+0x93) [0x5062d3] ./perf() [0x455ffa] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1fc9fc4af5] ./perf() [0x4220a9] Refcount +1 => 2 at ./perf(maps__insert+0x9a) [0x4bfd6a] ./perf(machine__create_kernel_maps+0xc3) [0x4bb1a3] ./perf(machine__new_host+0xfa) [0x4bb41a] ./perf(init_probe_symbol_maps+0x93) [0x5062d3] ./perf() [0x455ffa] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1fc9fc4af5] ./perf() [0x4220a9] Refcount -1 => 1 at ./perf(map_groups__exit+0x94) [0x4bea74] ./perf(machine__delete+0x3d) [0x4b91fd] ./perf(exit_probe_symbol_maps+0x28) [0x506378] ./perf() [0x45628a] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1fc9fc4af5] ./perf() [0x4220a9] map__new2() returns map with refcnt = 1, and also map_groups__insert gets it again in__machine__create_kernel_maps(). machine__destroy_kernel_maps() calls map_groups__remove() to decrement the refcnt, but before decrement it again (corresponding to map__new2), it makes vmlinux_maps[type] = NULL. And this may cause a refcnt leak. Signed-off-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20151118064022.30709.3897.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 0487d77..e9e09be 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -790,6 +790,7 @@ void machine__destroy_kernel_maps(struct machine *machine) kmap->ref_reloc_sym = NULL; } + map__put(machine->vmlinux_maps[type]); machine->vmlinux_maps[type] = NULL; } } -- 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/