From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752251AbbCUS4W (ORCPT ); Sat, 21 Mar 2015 14:56:22 -0400 Received: from mail.kernel.org ([198.145.29.136]:50144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752166AbbCUSzz (ORCPT ); Sat, 21 Mar 2015 14:55:55 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Adrian Hunter , Corey Ashford , David Ahern , Frederic Weisbecker , Paul Mackerras , Peter Zijlstra , Stephane Eranian , Arnaldo Carvalho de Melo Subject: [PATCH 18/19] perf tools: Add machine__module_dso function Date: Sat, 21 Mar 2015 15:54:37 -0300 Message-Id: <1426964078-16384-19-git-send-email-acme@kernel.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1426964078-16384-1-git-send-email-acme@kernel.org> References: <1426964078-16384-1-git-send-email-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa 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 24f8c978cfd4..dbb5f0367005 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; } -- 1.9.3