perf machine: No need to have two DSOs lists
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 3d39ac538629e4f00a6e1c38d46346f1b8e69505 Gitweb: http://git.kernel.org/tip/3d39ac538629e4f00a6e1c38d46346f1b8e69505 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 28 May 2015 13:06:42 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 29 May 2015 12:43:43 -0300
perf machine: No need to have two DSOs lists
We can, given a DSO, figure out if it is a kernel, a kernel module or a userlevel DSO, so stop having to process two lists in several functions.
If searching becomes an issue at some point, we can have them in a rbtree, etc.
Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/tests/hists_common.c | 2 +- tools/perf/util/build-id.c | 59 +++++++++++------------------------------ tools/perf/util/dso.c | 2 +- tools/perf/util/header.c | 6 +---- tools/perf/util/machine.c | 28 ++++++++----------- tools/perf/util/machine.h | 3 +-- tools/perf/util/map.c | 2 +- tools/perf/util/probe-event.c | 5 ++-- tools/perf/util/symbol-elf.c | 6 +---- tools/perf/util/vdso.c | 6 ++--- 10 files changed, 39 insertions(+), 80 deletions(-)
tools/perf/tests/hists_common.c +1 -1
@@ -121,7 +121,7 @@ struct machine *setup_fake_machine(struct machines *machines)size_t k;struct dso *dso; - dso =__dsos__findnew (&machine->user_dsos, + dso =__dsos__findnew (&machine->dsos, fake_symbols[i].dso_name);if (dso ==NULL ) goto out;
tools/perf/util/build-id.c +16 -43
96 lines not on this page · raw message
tools/perf/util/dso.c +1 -1
@@ -833,7 +833,7 @@ struct dso *machine__findnew_kernel(struct machine *machine, const char *name,/* * The kernel dso could be created by build_id processing. */ -struct dso *dso =__dsos__findnew (&machine->kernel_dsos, name); +struct dso *dso =__dsos__findnew (&machine->dsos, name);/* * We need to run this in all cases, since during the build_id
tools/perf/util/header.c +1 -5
@@ -1238,7 +1238,6 @@ static int __event_process_build_id(struct build_id_event *bev, struct perf_session *session) {int err =-1 ; -struct dsos *dsos;struct machine *machine;u16 misc;struct dso *dso;
@@ -1253,22 +1252,19 @@ static int __event_process_build_id(struct build_id_event *bev,switch (misc) {case PERF_RECORD_MISC_KERNEL : dso_type =DSO_TYPE_KERNEL ; - dsos = &machine->kernel_dsos;break ;case PERF_RECORD_MISC_GUEST_KERNEL : dso_type =DSO_TYPE_GUEST_KERNEL ; - dsos = &machine->kernel_dsos;break ;case PERF_RECORD_MISC_USER :case PERF_RECORD_MISC_GUEST_USER : dso_type =DSO_TYPE_USER ; - dsos = &machine->user_dsos;break ;default : goto out; } - dso =__dsos__findnew (dsos, filename); + dso =__dsos__findnew (&machine->dsos, filename);if (dso !=NULL ) {char sbuild_id[BUILD_ID_SIZE *2 +1 ];
tools/perf/util/machine.c +11 -17
@@ -26,8 +26,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) {map_groups__init (&machine->kmaps, machine);RB_CLEAR_NODE (&machine->rb_node); -dsos__init (&machine->user_dsos); -dsos__init (&machine->kernel_dsos); +dsos__init (&machine->dsos); machine->threads =RB_ROOT ;pthread_rwlock_init (&machine->threads_lock,NULL );
@@ -111,8 +110,7 @@ void machine__delete_threads(struct machine *machine)void machine__exit (struct machine *machine) {map_groups__exit (&machine->kmaps); -dsos__delete (&machine->user_dsos); -dsos__delete (&machine->kernel_dsos); +dsos__delete (&machine->dsos);vdso__exit (machine);zfree (&machine->root_dir);zfree (&machine->current_tid);
@@ -490,9 +488,9 @@ machine__module_dso(struct machine *machine, struct kmod_path *m, {struct dso *dso; - dso =dsos__find (&machine->kernel_dsos, m->name, true); + dso =dsos__find (&machine->dsos, m->name, true);if (!dso) { - dso =dsos__addnew (&machine->kernel_dsos, m->name); + dso =dsos__addnew (&machine->dsos, m->name);if (dso ==NULL )return NULL ;
@@ -561,13 +559,11 @@ out:size_t machines__fprintf_dsos (struct machines *machines,FILE *fp) {struct rb_node *nd; -size_t ret =__dsos__fprintf (&machines->host.kernel_dsos.head, fp) + -__dsos__fprintf (&machines->host.user_dsos.head, fp); +size_t ret =__dsos__fprintf (&machines->host.dsos.head, fp);for (nd =rb_first (&machines->guests); nd; nd =rb_next (nd)) { struct machine *pos = rb_entry(nd, struct machine, rb_node); - ret +=__dsos__fprintf (&pos->kernel_dsos.head, fp); - ret +=__dsos__fprintf (&pos->user_dsos.head, fp); + ret +=__dsos__fprintf (&pos->dsos.head, fp); }return ret;
@@ -576,8 +572,7 @@ size_t machines__fprintf_dsos(struct machines *machines, FILE *fp)size_t machine__fprintf_dsos_buildid (struct machine *m,FILE *fp,bool (skip )(struct dso *dso,int parm),int parm) { -return __dsos__fprintf_buildid (&m->kernel_dsos.head, fp, skip, parm) + -__dsos__fprintf_buildid (&m->user_dsos.head, fp, skip, parm); +return __dsos__fprintf_buildid (&m->dsos.head, fp, skip, parm); } size_t machines__fprintf_dsos_buildid(struct machines *machines, FILE *fp,
@@ -1106,7 +1101,7 @@ static bool machine__uses_kcore(struct machine *machine) {struct dso *dso; -list_for_each_entry (dso, &machine->kernel_dsos.head, node) { +list_for_each_entry (dso, &machine->dsos.head, node) {if (dso__is_kcore (dso))return true; }
@@ -1153,8 +1148,8 @@ static int machine__process_kernel_mmap_event(struct machine *machine,struct dso *kernel =NULL ;struct dso *dso; -list_for_each_entry (dso, &machine->kernel_dsos.head, node) { -if (is_kernel_module (dso->long_name)) +list_for_each_entry (dso, &machine->dsos.head, node) { +if (dso->kernel &&is_kernel_module (dso->long_name))continue ; kernel = dso;
@@ -1162,8 +1157,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine, }if (kernel ==NULL ) - kernel =__dsos__findnew (&machine->kernel_dsos, - kmmap_prefix); + kernel =__dsos__findnew (&machine->dsos, kmmap_prefix);if (kernel ==NULL ) goto out_problem;
tools/perf/util/machine.h +1 -2
@@ -34,8 +34,7 @@ struct machine {struct list_head dead_threads;struct thread *last_match;struct vdso_info *vdso_info; -struct dsos user_dsos; -struct dsos kernel_dsos; +struct dsos dsos;struct map_groups kmaps;struct map *vmlinux_maps[MAP__NR_TYPES ];u64 kernel_start;
tools/perf/util/map.c +1 -1
@@ -180,7 +180,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, pgoff =0 ; dso =vdso__dso_findnew (machine, thread); }else - dso =__dsos__findnew (&machine->user_dsos, filename); + dso =__dsos__findnew (&machine->dsos, filename);if (dso ==NULL ) goto out_delete;
tools/perf/util/probe-event.c +3 -2
@@ -256,8 +256,9 @@ static int kernel_get_module_dso(const char *module, struct dso **pdso)int ret =0 ;if (module) { -list_for_each_entry (dso, &host_machine->kernel_dsos.head, - node) { +list_for_each_entry (dso, &host_machine->dsos.head, node) { +if (!dso->kernel) +continue ;if (strncmp (dso->short_name +1 , module, dso->short_name_len -2 ) ==0 ) goto found;
tools/perf/util/symbol-elf.c +1 -5
@@ -1031,11 +1031,7 @@ int dso__load_sym(struct dso *dso, struct map *map, } curr_dso->symtab_type = dso->symtab_type;map_groups__insert (kmaps, curr_map); -/* -* The new DSO should go to the kernel DSOS -*/ -dsos__add (&map->groups->machine->kernel_dsos, - curr_dso); +dsos__add (&map->groups->machine->dsos, curr_dso);dso__set_loaded (curr_dso, map->type); }else curr_dso = curr_map->dso;
tools/perf/util/vdso.c +3 -3
@@ -127,7 +127,7 @@ static struct dso *vdso__new(struct machine *machine, const char *short_name, dso =dso__new (short_name);if (dso !=NULL ) { -dsos__add (&machine->user_dsos, dso); +dsos__add (&machine->dsos, dso);dso__set_long_name (dso, long_name, false); }
@@ -236,7 +236,7 @@ static struct dso *vdso__findnew_compat(struct machine *machine,const char *file_name;struct dso *dso; - dso =dsos__find (&machine->user_dsos, vdso_file->dso_name, true); + dso =dsos__find (&machine->dsos, vdso_file->dso_name, true);if (dso)return dso;
@@ -299,7 +299,7 @@ struct dso *vdso__dso_findnew(struct machine *machine,return dso;#endif - dso =dsos__find (&machine->user_dsos,DSO__NAME_VDSO , true); + dso =dsos__find (&machine->dsos,DSO__NAME_VDSO , true);if (!dso) {char *file;