aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-02-17 11:29:57 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-21 13:58:07 -0400
commitca33380adf74afb985bf7aab09ec46707a5d2d57 (patch)
tree802d8e661a20c6d59867703140865dfd98d5db9c /tools
parentda17ea33e5a5d0c5226a37c375575d689f6a741b (diff)
perf tools: Use kmod_path__parse for machine__new_dso
Using kmod_path__parse to get the module name and update the dso short name within machine__new_dso function. This way it's done only first time when dso is created, unlike the current way when we update it all the time we process memory map of the kernel module. 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-8gjmt1ggf5ls1xkk7qi2ko4k@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/machine.c59
1 files changed, 21 insertions, 38 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index dbb5f0367005..eb95b883fb44 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -460,14 +460,15 @@ 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) 463static struct dso*
464machine__module_dso(struct machine *machine, struct kmod_path *m,
465 const char *filename)
464{ 466{
465 struct dso *dso; 467 struct dso *dso;
466 bool compressed;
467 468
468 dso = dsos__find(&machine->kernel_dsos, filename, false); 469 dso = dsos__find(&machine->kernel_dsos, m->name, true);
469 if (!dso) { 470 if (!dso) {
470 dso = dsos__addnew(&machine->kernel_dsos, filename); 471 dso = dsos__addnew(&machine->kernel_dsos, m->name);
471 if (dso == NULL) 472 if (dso == NULL)
472 return NULL; 473 return NULL;
473 474
@@ -477,8 +478,11 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
477 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE; 478 dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
478 479
479 /* _KMODULE_COMP should be next to _KMODULE */ 480 /* _KMODULE_COMP should be next to _KMODULE */
480 if (is_kernel_module(filename, &compressed) && compressed) 481 if (m->kmod && m->comp)
481 dso->symtab_type++; 482 dso->symtab_type++;
483
484 dso__set_short_name(dso, strdup(m->name), true);
485 dso__set_long_name(dso, strdup(filename), true);
482 } 486 }
483 487
484 return dso; 488 return dso;
@@ -487,17 +491,25 @@ static struct dso *machine__module_dso(struct machine *machine, const char *file
487struct map *machine__new_module(struct machine *machine, u64 start, 491struct map *machine__new_module(struct machine *machine, u64 start,
488 const char *filename) 492 const char *filename)
489{ 493{
490 struct map *map; 494 struct map *map = NULL;
491 struct dso *dso = machine__module_dso(machine, filename); 495 struct dso *dso;
496 struct kmod_path m;
492 497
493 if (dso == NULL) 498 if (kmod_path__parse_name(&m, filename))
494 return NULL; 499 return NULL;
495 500
501 dso = machine__module_dso(machine, &m, filename);
502 if (dso == NULL)
503 goto out;
504
496 map = map__new2(start, dso, MAP__FUNCTION); 505 map = map__new2(start, dso, MAP__FUNCTION);
497 if (map == NULL) 506 if (map == NULL)
498 return NULL; 507 goto out;
499 508
500 map_groups__insert(&machine->kmaps, map); 509 map_groups__insert(&machine->kmaps, map);
510
511out:
512 free(m.name);
501 return map; 513 return map;
502} 514}
503 515
@@ -1058,40 +1070,11 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
1058 strlen(kmmap_prefix) - 1) == 0; 1070 strlen(kmmap_prefix) - 1) == 0;
1059 if (event->mmap.filename[0] == '/' || 1071 if (event->mmap.filename[0] == '/' ||
1060 (!is_kernel_mmap && event->mmap.filename[0] == '[')) { 1072 (!is_kernel_mmap && event->mmap.filename[0] == '[')) {
1061
1062 char short_module_name[1024];
1063 char *name, *dot;
1064
1065 if (event->mmap.filename[0] == '/') {
1066 name = strrchr(event->mmap.filename, '/');
1067 if (name == NULL)
1068 goto out_problem;
1069
1070 ++name; /* skip / */
1071 dot = strrchr(name, '.');
1072 if (dot == NULL)
1073 goto out_problem;
1074 /* On some system, modules are compressed like .ko.gz */
1075 if (is_supported_compression(dot + 1))
1076 dot -= 3;
1077 if (!is_kmodule_extension(dot + 1))
1078 goto out_problem;
1079 snprintf(short_module_name, sizeof(short_module_name),
1080 "[%.*s]", (int)(dot - name), name);
1081 strxfrchar(short_module_name, '-', '_');
1082 } else
1083 strcpy(short_module_name, event->mmap.filename);
1084
1085 map = machine__new_module(machine, event->mmap.start, 1073 map = machine__new_module(machine, event->mmap.start,
1086 event->mmap.filename); 1074 event->mmap.filename);
1087 if (map == NULL) 1075 if (map == NULL)
1088 goto out_problem; 1076 goto out_problem;
1089 1077
1090 name = strdup(short_module_name);
1091 if (name == NULL)
1092 goto out_problem;
1093
1094 dso__set_short_name(map->dso, name, true);
1095 map->end = map->start + event->mmap.len; 1078 map->end = map->start + event->mmap.len;
1096 } else if (is_kernel_mmap) { 1079 } else if (is_kernel_mmap) {
1097 const char *symbol_name = (event->mmap.filename + 1080 const char *symbol_name = (event->mmap.filename +