perf tools: Add machine__module_dso function
tip-bot for Jiri Olsa
merge botCommit-ID: da17ea33e5a5d0c5226a37c375575d689f6a741b Gitweb: http://git.kernel.org/tip/da17ea33e5a5d0c5226a37c375575d689f6a741b Author: Jiri Olsa <[email protected]> AuthorDate: Thu, 12 Feb 2015 22:10:52 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> 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 <[email protected]>
Acked-by Namhyung Kim <[email protected]>
Cc Adrian Hunter <[email protected]>
Cc Corey Ashford <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/machine.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
tools/perf/util/machine.c +25 -11
@@ -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; }