From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752800AbbCVKTR (ORCPT ); Sun, 22 Mar 2015 06:19:17 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57494 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbbCVKTP (ORCPT ); Sun, 22 Mar 2015 06:19:15 -0400 Date: Sun, 22 Mar 2015 03:18:56 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: acme@redhat.com, eranian@google.com, jolsa@kernel.org, dsahern@gmail.com, tglx@linutronix.de, fweisbec@gmail.com, paulus@samba.org, hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl, cjashfor@linux.vnet.ibm.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, adrian.hunter@intel.com Reply-To: tglx@linutronix.de, fweisbec@gmail.com, paulus@samba.org, hpa@zytor.com, acme@redhat.com, eranian@google.com, jolsa@kernel.org, dsahern@gmail.com, adrian.hunter@intel.com, mingo@kernel.org, a.p.zijlstra@chello.nl, cjashfor@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, namhyung@kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add machine__module_dso function Git-Commit-ID: da17ea33e5a5d0c5226a37c375575d689f6a741b 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 Commit-ID: da17ea33e5a5d0c5226a37c375575d689f6a741b Gitweb: http://git.kernel.org/tip/da17ea33e5a5d0c5226a37c375575d689f6a741b Author: Jiri Olsa AuthorDate: Thu, 12 Feb 2015 22:10:52 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Sat, 21 Mar 2015 14:55:48 -0300 perf tools: Add machine__module_dso function Separate the dso object addition and update when adding new kernel module. Currently we update dso's symtab_type any time we find it in the list, because we can't distinguish between new and found dso from __dsos__findnew function. Adding machine__module_dso that separates finding and adding new dso objects, so there's no superfluous update of dso. Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-uvqgs5tyq4wssnq6fm43hgvk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 24f8c97..dbb5f03 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -460,12 +460,35 @@ int machine__process_lost_event(struct machine *machine __maybe_unused, return 0; } +static struct dso *machine__module_dso(struct machine *machine, const char *filename) +{ + struct dso *dso; + bool compressed; + + dso = dsos__find(&machine->kernel_dsos, filename, false); + if (!dso) { + dso = dsos__addnew(&machine->kernel_dsos, filename); + if (dso == NULL) + return NULL; + + if (machine__is_host(machine)) + dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE; + else + dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; + + /* _KMODULE_COMP should be next to _KMODULE */ + if (is_kernel_module(filename, &compressed) && compressed) + dso->symtab_type++; + } + + return dso; +} + struct map *machine__new_module(struct machine *machine, u64 start, const char *filename) { struct map *map; - struct dso *dso = __dsos__findnew(&machine->kernel_dsos, filename); - bool compressed; + struct dso *dso = machine__module_dso(machine, filename); if (dso == NULL) return NULL; @@ -474,15 +497,6 @@ struct map *machine__new_module(struct machine *machine, u64 start, if (map == NULL) return NULL; - if (machine__is_host(machine)) - dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE; - else - dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; - - /* _KMODULE_COMP should be next to _KMODULE */ - if (is_kernel_module(filename, &compressed) && compressed) - dso->symtab_type++; - map_groups__insert(&machine->kmaps, map); return map; }