Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752787AbbKWQM2 (ORCPT ); Mon, 23 Nov 2015 11:12:28 -0500 Received: from terminus.zytor.com ([198.137.202.10]:43965 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbbKWQMY (ORCPT ); Mon, 23 Nov 2015 11:12:24 -0500 Date: Mon, 23 Nov 2015 08:12:07 -0800 From: tip-bot for Masami Hiramatsu Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, masami.hiramatsu.pt@hitachi.com, jolsa@redhat.com, tglx@linutronix.de, acme@redhat.com, namhyung@kernel.org, mingo@kernel.org, a.p.zijlstra@chello.nl, adrian.hunter@intel.com Reply-To: acme@redhat.com, adrian.hunter@intel.com, a.p.zijlstra@chello.nl, mingo@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, jolsa@redhat.com, masami.hiramatsu.pt@hitachi.com In-Reply-To: <20151118064026.30709.50038.stgit@localhost.localdomain> References: <20151118064026.30709.50038.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Fix to put new map after inserting to map_groups in dso__load_sym Git-Commit-ID: 8d5c340dfcd48751fdff301bb2a7e3f875652dcb 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: 3323 Lines: 87 Commit-ID: 8d5c340dfcd48751fdff301bb2a7e3f875652dcb Gitweb: http://git.kernel.org/tip/8d5c340dfcd48751fdff301bb2a7e3f875652dcb Author: Masami Hiramatsu AuthorDate: Wed, 18 Nov 2015 15:40:27 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 19 Nov 2015 13:19:20 -0300 perf tools: Fix to put new map after inserting to map_groups in dso__load_sym Fix dso__load_sym to put the map object which is already insterted to kmaps. Refcnt debugger shows ==== [0] ==== Unreclaimed map: 0x39113e0 Refcount +1 => 1 at ./perf(map__new2+0xb5) [0x4be155] ./perf(dso__load_sym+0xee1) [0x503461] ./perf(dso__load_vmlinux+0xbf) [0x4aa6df] ./perf(dso__load_vmlinux_path+0x8c) [0x4aa83c] ./perf() [0x50528a] ./perf(convert_perf_probe_events+0xd79) [0x50ac29] ./perf() [0x45600f] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5] ./perf() [0x4220a9] Refcount +1 => 2 at ./perf(maps__insert+0x9a) [0x4bfffa] ./perf(dso__load_sym+0xf89) [0x503509] ./perf(dso__load_vmlinux+0xbf) [0x4aa6df] ./perf(dso__load_vmlinux_path+0x8c) [0x4aa83c] ./perf() [0x50528a] ./perf(convert_perf_probe_events+0xd79) [0x50ac29] ./perf() [0x45600f] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5] ./perf() [0x4220a9] Refcount -1 => 1 at ./perf(map_groups__exit+0x94) [0x4bed04] ./perf(machine__delete+0xb0) [0x4b9300] ./perf(exit_probe_symbol_maps+0x28) [0x506608] ./perf() [0x45628a] ./perf(cmd_probe+0x6c) [0x4566bc] ./perf() [0x47abc5] ./perf(main+0x610) [0x421f90] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5] ./perf() [0x4220a9] This means that the dso__load_sym calls map__new2 and maps_insert, both of them bump the map refcount, but map_groups__exit will drop just one reference. Fix it by dropping the refcount after inserting it into kmaps. Signed-off-by: Masami Hiramatsu Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20151118064026.30709.50038.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol-elf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 475d88d..53f1996 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1042,6 +1042,8 @@ int dso__load_sym(struct dso *dso, struct map *map, } curr_dso->symtab_type = dso->symtab_type; map_groups__insert(kmaps, curr_map); + /* kmaps already got it */ + map__put(curr_map); dsos__add(&map->groups->machine->dsos, curr_dso); dso__set_loaded(curr_dso, map->type); } else -- 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/