aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-02-12 16:10:52 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-21 13:55:48 -0400
commitda17ea33e5a5d0c5226a37c375575d689f6a741b (patch)
treeffa42f5091b10413cd898df6cf40950077586c30 /tools
parent701d8d7f861ec36f3bc60d1ddb185cceb7919c79 (diff)
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 <jolsa@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-uvqgs5tyq4wssnq6fm43hgvk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/machine.c36
1 files 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,
460 return 0; 460 return 0;
461} 461}
462 462
463static struct dso *machine__module_dso(struct machine *machine, const char *filename)
464{
465 struct dso *dso;
466 bool compressed;
467
468 dso = dsos__find(&machine->kernel_dsos, filename, false);
469 if (!dso) {
470 dso = dsos__addnew(&machine->kernel_dsos, filename);
471 if (dso == NULL)
472 return NULL;
473
474 if (machine__is_host(machine))
475 dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
476 else
477 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
478
479 /* _KMODULE_COMP should be next to _KMODULE */
480 if (is_kernel_module(filename, &compressed) && compressed)
481 dso->symtab_type++;
482 }
483
484 return dso;
485}
486
463struct map *machine__new_module(struct machine *machine, u64 start, 487struct map *machine__new_module(struct machine *machine, u64 start,
464 const char *filename) 488 const char *filename)
465{ 489{
466 struct map *map; 490 struct map *map;
467 struct dso *dso = __dsos__findnew(&machine->kernel_dsos, filename); 491 struct dso *dso = machine__module_dso(machine, filename);
468 bool compressed;
469 492
470 if (dso == NULL) 493 if (dso == NULL)
471 return NULL; 494 return NULL;
@@ -474,15 +497,6 @@ struct map *machine__new_module(struct machine *machine, u64 start,
474 if (map == NULL) 497 if (map == NULL)
475 return NULL; 498 return NULL;
476 499
477 if (machine__is_host(machine))
478 dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
479 else
480 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
481
482 /* _KMODULE_COMP should be next to _KMODULE */
483 if (is_kernel_module(filename, &compressed) && compressed)
484 dso->symtab_type++;
485
486 map_groups__insert(&machine->kmaps, map); 500 map_groups__insert(&machine->kmaps, map);
487 return map; 501 return map;
488} 502}