perf buildid-list: No need to process the header sections again
PATCH 1/6 perf buildid-list: No need to process the header sections again
From: Arnaldo Carvalho de Melo <[email protected]>
As it is already processed by:
perf_session__new
perf_session__open
perf_session__read
This was harmless, because we use dsos__findnew, that would already find it, but is unnecessary work and removing it makes builtin-buildid-list.c even shorter.
--- tools/perf/builtin-buildid-list.c | 25 +------------------------ 1 files changed, 1 insertions(+), 24 deletions(-)
tools/perf/builtin-buildid-list.c +1 -24
@@ -31,26 +31,6 @@ static const struct option options[] = { OPT_END() }; -static int perf_file_section__process_buildids (struct perf_file_section *self, -int feat,int fd) -{ -if (feat !=HEADER_BUILD_ID ) -return 0 ; - -if (lseek (fd, self->offset,SEEK_SET ) <0 ) { -pr_warning ("Failed to lseek to %Ld offset for buildids!\n" , - self->offset); -return -1 ; - } - -if (perf_header__read_build_ids (fd, self->offset, self->size)) { -pr_warning ("Failed to read buildids!\n" ); -return -1 ; - } - -return 0 ; -} -static int __cmd_buildid_list (void ) {int err =-1 ;
@@ -60,10 +40,7 @@ static int __cmd_buildid_list(void)if (session ==NULL )return -1 ; - err =perf_header__process_sections (&session->header, session->fd, - perf_file_section__process_buildids); -if (err >=0 ) -dsos__fprintf_buildid (stdout); +dsos__fprintf_buildid (stdout);perf_session__delete (session);return err;
Signature · 1 line
1.6.2.5
PATCH 2/6 perf symbols: Record the domain of DSOs in HEADER_BUILD_ID header table
From: Arnaldo Carvalho de Melo <[email protected]>
So that we can restore them to the right DSO list (either dsos__kernel or dsos__user).
We do that just like the kernel does for the other events, encoding PERF_RECORD_MISC_{KERNEL,USER} in perf_event_header.
--- tools/perf/util/header.c | 9 ++++++--- tools/perf/util/session.c | 6 +++++- tools/perf/util/symbol.c | 6 +++--- tools/perf/util/symbol.h | 11 +++++++++-- 4 files changed, 23 insertions(+), 9 deletions(-)
tools/perf/util/header.c +6 -3
@@ -193,7 +193,7 @@ static int write_padded(int fd, const void *bf, size_t count,continue ; \ else -static int __dsos__write_buildid_table(struct list_head *head, int fd) +static int __dsos__write_buildid_table(struct list_head *head, u16 misc, int fd) {struct dso *pos;
@@ -205,6 +205,7 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd) len =ALIGN (len,NAME_ALIGN );memset (&b,0 ,sizeof (b));memcpy (&b.build_id, pos->build_id,sizeof (pos->build_id)); + b.header.misc = misc; b.header.size =sizeof (b) + len; err =do_write (fd, &b,sizeof (b));if (err <0 )
@@ -220,9 +221,11 @@ static int __dsos__write_buildid_table(struct list_head *head, int fd)static int dsos__write_buildid_table (int fd) { -int err =__dsos__write_buildid_table (&dsos__kernel, fd); +int err =__dsos__write_buildid_table (&dsos__kernel, +PERF_RECORD_MISC_KERNEL , fd);if (err ==0 ) - err =__dsos__write_buildid_table (&dsos__user, fd); + err =__dsos__write_buildid_table (&dsos__user, +PERF_RECORD_MISC_USER , fd);return err; }
tools/perf/util/session.c +5 -1
@@ -255,6 +255,7 @@ int perf_header__read_build_ids(int input, u64 offset, u64 size)while (offset < limit) {struct dso *dso;ssize_t len; +struct list_head *head = &dsos__user;if (read (input, &bev,sizeof (bev)) !=sizeof (bev)) goto out;
@@ -263,7 +264,10 @@ int perf_header__read_build_ids(int input, u64 offset, u64 size)if (read (input, filename, len) != len) goto out; - dso =dsos__findnew (filename); +if (bev.header.misc &PERF_RECORD_MISC_KERNEL ) + head = &dsos__kernel; + + dso =__dsos__findnew (head, filename);if (dso !=NULL )dso__set_build_id (dso, &bev.build_id);
tools/perf/util/symbol.c +3 -3
@@ -1615,14 +1615,14 @@ static struct dso *dsos__find(struct list_head *head, const char *name)return NULL ; } -struct dso *dsos__findnew (const char *name) +struct dso *__dsos__findnew (struct list_head *head,const char *name) { -struct dso *dso =dsos__find (&dsos__user, name); +struct dso *dso =dsos__find (head, name);if (!dso) { dso =dso__new (name);if (dso !=NULL ) { -dsos__add (&dsos__user, dso); +dsos__add (head, dso);dso__set_basename (dso); } }
tools/perf/util/symbol.h +9 -2
@@ -115,9 +115,17 @@ bool dso__sorted_by_name(const struct dso *self, enum map_type type);void dso__sort_by_name (struct dso *self,enum map_type type); +extern struct list_head dsos__user, dsos__kernel; + +struct dso *__dsos__findnew (struct list_head *head,const char *name); + +static inline struct dso *dsos__findnew (const char *name) +{ +return __dsos__findnew (&dsos__user, name); +} +struct perf_session ; -struct dso *dsos__findnew (const char *name);int dso__load (struct dso *self,struct map *map,struct perf_session *session,symbol_filter_t filter);void dsos__fprintf (FILE *fp);
@@ -143,6 +151,5 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);int perf_session__create_kernel_maps (struct perf_session *self); -extern struct list_head dsos__user, dsos__kernel;extern struct dso *vdso;#endif /* __PERF_SYMBOL */
Signature · 1 line
1.6.2.5
PATCH 3/6 perf tools: Create typedef for common event synthesizing callback
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/event.c | 16 +++++----------- tools/perf/util/event.h | 12 +++++------- 2 files changed, 10 insertions(+), 18 deletions(-)
tools/perf/util/event.c +5 -11
@@ -8,8 +8,7 @@#include "thread.h" static pid_t event__synthesize_comm (pid_t pid,int full, -int (*process)(event_t *event, -struct perf_session *session), +event__handler_t process,struct perf_session *session) {event_t ev;
@@ -91,8 +90,7 @@ out_failure: }static int event__synthesize_mmap_events (pid_t pid,pid_t tgid, -int (*process)(event_t *event, -struct perf_session *session), +event__handler_t process,struct perf_session *session) {char filename[PATH_MAX ];
@@ -156,9 +154,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,return 0 ; } -int event__synthesize_thread (pid_t pid, -int (*process)(event_t *event, -struct perf_session *session), +int event__synthesize_thread (pid_t pid,event__handler_t process,struct perf_session *session) {pid_t tgid =event__synthesize_comm (pid,1 , process, session);
@@ -167,8 +163,7 @@ int event__synthesize_thread(pid_t pid,return event__synthesize_mmap_events (pid, tgid, process, session); } -void event__synthesize_threads (int (*process)(event_t *event, -struct perf_session *session), +void event__synthesize_threads (event__handler_t process,struct perf_session *session) {DIR *proc;
@@ -205,8 +200,7 @@ static int find_symbol_cb(void *arg, const char *name, char type, u64 start)return 1 ; } -int event__synthesize_kernel_mmap (int (*process)(event_t *event, -struct perf_session *session), +int event__synthesize_kernel_mmap (event__handler_t process,struct perf_session *session,const char *symbol_name) {
tools/perf/util/event.h +5 -7
@@ -103,15 +103,13 @@ void event__print_totals(void);struct perf_session ; -int event__synthesize_thread (pid_t pid, -int (*process)(event_t *event, -struct perf_session *session), +typedef int (*event__handler_t )(event_t *event,struct perf_session *session); + +int event__synthesize_thread (pid_t pid,event__handler_t process,struct perf_session *session); -void event__synthesize_threads (int (*process)(event_t *event, -struct perf_session *session), +void event__synthesize_threads (event__handler_t process,struct perf_session *session); -int event__synthesize_kernel_mmap (int (*process)(event_t *event, -struct perf_session *session), +int event__synthesize_kernel_mmap (event__handler_t process,struct perf_session *session,const char *symbol_name);
Signature · 1 line
1.6.2.5
PATCH 4/6 rbtree: Introduce rb_for_each_entry
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Similar to list_for_each_entry, helps reducing boilerplate in many places and makes rbtrees closer to list.h macros.
First conversion will be in the tools/perf.
--- include/linux/rbtree.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
include/linux/rbtree.h +12 -0
@@ -158,4 +158,16 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent, *rb_link = node; } +/** +* rb_for_each_entry - iterate over rbtree of given type +* @pos: the type * to hold the current entry being traversed +* @node: the rb_node to hold the current entry being traversed +* @root: the root for your tree. +* @member: the name of the rb_node within the struct. +*/ +#define rb_for_each_entry (pos, node, root, member) \ + for (node = rb_first(root); \ + node && (pos = rb_entry(node, typeof(*pos), member)); \ + node = rb_next(node)) +#endif /* _LINUX_RBTREE_H */
Signature · 1 line
1.6.2.5
PATCH 5/6 perf tools: Use rb_for_each_entry
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/builtin-annotate.c | 19 ++++++------------- tools/perf/builtin-diff.c | 5 ++--- tools/perf/builtin-kmem.c | 12 +++++------- tools/perf/builtin-sched.c | 10 ++-------- tools/perf/builtin-top.c | 10 +++------- tools/perf/util/symbol.c | 16 ++++++---------- 6 files changed, 24 insertions(+), 48 deletions(-)
tools/perf/builtin-annotate.c +6 -13
@@ -349,19 +349,12 @@ static void print_summary(const char *filename)return ; } - node =rb_first (&root_sym_ext); -while (node) { -double percent; -const char *color; -char *path; - - sym_ext = rb_entry(node, struct sym_ext, node); - percent = sym_ext->percent; - color =get_percent_color (percent); - path = sym_ext->path; +rb_for_each_entry (sym_ext, node, &root_sym_ext, node) { +double percent = sym_ext->percent; +const char *color =get_percent_color (percent); +char *path = sym_ext->path;color_fprintf (stdout, color," %7.2f %s" , percent, path); - node =rb_next (node); } }
@@ -428,9 +421,9 @@ static void annotate_sym(struct hist_entry *he)static void perf_session__find_annotations (struct perf_session *self) {struct rb_node *nd; +struct hist_entry *he; -for (nd =rb_first (&self->hists); nd; nd =rb_next (nd)) { - struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); +rb_for_each_entry (he, nd, &self->hists, rb_node) {struct sym_priv *priv;if (he->sym ==NULL )
tools/perf/builtin-diff.c +2 -3
@@ -143,11 +143,10 @@ static void perf_session__match_hists(struct perf_session *old_session, struct perf_session *new_session) {struct rb_node *nd; +struct hist_entry *pos; -for (nd =rb_first (&new_session->hists); nd; nd =rb_next (nd)) { - struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node); +rb_for_each_entry (pos, nd, &new_session->hists, rb_node) pos->pair =perf_session__find_hist_entry (old_session, pos); - } }static int __cmd_diff (void )
tools/perf/builtin-kmem.c +5 -7
@@ -354,21 +354,21 @@ static void __print_result(struct rb_root *root, struct perf_session *session, int n_lines, int is_caller) {struct rb_node *next; +struct alloc_stat *data;printf ("%.102s\n" , graph_dotted_line);printf (" %-34s |" , is_caller ?"Callsite" :"Alloc Ptr" );printf (" Total_alloc/Per | Total_req/Per | Hit | Ping-pong | Frag\n" );printf ("%.102s\n" , graph_dotted_line); - next =rb_first (root); - -while (next && n_lines--) { - struct alloc_stat *data = rb_entry(next, struct alloc_stat, - node); +rb_for_each_entry (data, next, root, node) {struct symbol *sym =NULL ;char buf[BUFSIZ ];u64 addr; +if (n_lines--) +break ; +if (is_caller) { addr = data->call_site;if (!raw_ip)
@@ -391,8 +391,6 @@ static void __print_result(struct rb_root *root, struct perf_session *session, (unsigned long )data->hit, (unsigned long )data->pingpong, fragmentation(data->bytes_req, data->bytes_alloc)); - - next =rb_next (next); }if (n_lines ==-1 )
tools/perf/builtin-sched.c +2 -8
@@ -1706,6 +1706,7 @@ static void print_bad_events(void)static void __cmd_lat (void ) {struct rb_node *next; +struct work_atoms *work_list;setup_pager ();read_events ();
@@ -1715,15 +1716,8 @@ static void __cmd_lat(void)printf (" Task | Runtime ms | Switches | Average delay ms | Maximum delay ms | Maximum delay at |\n" );printf (" ---------------------------------------------------------------------------------------------------------------\n" ); - next =rb_first (&sorted_atom_root); - -while (next) { -struct work_atoms *work_list; - - work_list = rb_entry(next, struct work_atoms, node); +rb_for_each_entry (work_list, next, &sorted_atom_root, node)output_lat_thread (work_list); - next =rb_next (next); - }printf (" -----------------------------------------------------------------------------------------\n" ); printf(" TOTAL: |%11.3f ms |%9Ld |\n",
tools/perf/builtin-top.c +3 -7
@@ -532,8 +532,7 @@ static void print_sym_table(void)/* * Find the longest symbol name that will be displayed */ -for (nd =rb_first (&tmp); nd; nd =rb_next (nd)) { - syme = rb_entry(nd, struct sym_entry, rb_node); +rb_for_each_entry (syme, nd, &tmp, rb_node) {if (++printed > print_entries || (int )syme->snap_count < count_filter)continue ;
@@ -567,13 +566,10 @@ static void print_sym_table(void)printf (" %-*.*s" , dso_width, dso_width, graph_line);puts ("\n" ); -for (nd =rb_first (&tmp); nd; nd =rb_next (nd)) { -struct symbol *sym; +rb_for_each_entry (syme, nd, &tmp, rb_node) { +struct symbol *sym =sym_entry__symbol (syme);double pcnt; - syme = rb_entry(nd, struct sym_entry, rb_node); - sym =sym_entry__symbol (syme); -if (++printed > print_entries || (int )syme->snap_count < count_filter)continue ;
tools/perf/util/symbol.c +6 -10
@@ -292,11 +292,10 @@ static void symbols__insert_by_name(struct rb_root *self, struct symbol *sym)static void symbols__sort_by_name (struct rb_root *self,struct rb_root *source) {struct rb_node *nd; +struct symbol *pos; -for (nd =rb_first (source); nd; nd =rb_next (nd)) { - struct symbol *pos = rb_entry(nd, struct symbol, rb_node); +rb_for_each_entry (pos, nd, source, rb_node)symbols__insert_by_name (self, pos); - } }static struct symbol *symbols__find_by_name (struct rb_root *self,const char *name)
@@ -371,14 +370,13 @@ size_t dso__fprintf_buildid(struct dso *self, FILE *fp)size_t dso__fprintf (struct dso *self,enum map_type type,FILE *fp) {struct rb_node *nd; +struct symbol *pos;size_t ret =fprintf (fp,"dso: %s (" , self->short_name); ret +=dso__fprintf_buildid (self, fp); ret +=fprintf (fp,")\n" ); -for (nd =rb_first (&self->symbols[type]); nd; nd =rb_next (nd)) { - struct symbol *pos = rb_entry(nd, struct symbol, rb_node); +rb_for_each_entry (pos, nd, &self->symbols[type], rb_node) ret +=symbol__fprintf (pos, fp); - }return ret; }
@@ -1339,13 +1337,11 @@ struct map *map_groups__find_by_name(struct map_groups *self, enum map_type type, const char *name) { struct rb_node *nd; +struct map *map; -for (nd =rb_first (&self->maps[type]); nd; nd =rb_next (nd)) { - struct map *map = rb_entry(nd, struct map, rb_node); - +rb_for_each_entry (map, nd, &self->maps[type], rb_node)if (map->dso &&strcmp (map->dso->name, name) ==0 )return map; - }return NULL ; }
Signature · 1 line
1.6.2.5
Re: [PATCH 5/6] perf tools: Use rb_for_each_entry
Quoted 7 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
Cc Fr??d??ric Weisbecker <[email protected]>Cc Mike Galbraith <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
Quoted 8 lines
--- tools/perf/builtin-annotate.c | 19 ++++++------------- tools/perf/builtin-diff.c | 5 ++--- tools/perf/builtin-kmem.c | 12 +++++------- tools/perf/builtin-sched.c | 10 ++-------- tools/perf/builtin-top.c | 10 +++------- tools/perf/util/symbol.c | 16 ++++++---------- 6 files changed, 24 insertions(+), 48 deletions(-)
hm, this one doesnt build very well:
touch .perf.dev.null
CC builtin-annotate.o
CC builtin-diff.o
CC builtin-sched.o
CC builtin-top.o
CC builtin-kmem.o
CC util/symbol.o
cc1: warnings being treated as errorsbuiltin-diff.c: In function 'perf_session__match_hists':
builtin-diff.c:148: error: implicit declaration of function 'rb_for_each_entry' builtin-diff.c:148: error: nested extern declaration of 'rb_for_each_entry' builtin-diff.c:148: error: 'rb_node' undeclared (first use in this function) builtin-diff.c:148: error: (Each undeclared identifier is reported only once builtin-diff.c:148: error: for each function it appears in.) builtin-diff.c:149: error: expected ';' before 'pos' builtin-diff.c:142: error: unused parameter 'old_session'
make: *** [builtin-diff.o] Error 1
make: *** Waiting for unfinished jobs....
cc1: warnings being treated as errorsbuiltin-annotate.c: In function 'print_summary':
builtin-annotate.c:352: error: implicit declaration of function 'rb_for_each_entry' builtin-annotate.c:352: error: nested extern declaration of 'rb_for_each_entry' builtin-annotate.c:352: error: expected ';' before '{' token builtin-annotate.c: In function 'perf_session__find_annotations':
builtin-annotate.c:426: error: 'rb_node' undeclared (first use in this function) builtin-annotate.c:426: error: (Each undeclared identifier is reported only once builtin-annotate.c:426: error: for each function it appears in.) builtin-annotate.c:426: error: expected ';' before '{' token
make: *** [builtin-annotate.o] Error 1
cc1: warnings being treated as errorsbuiltin-top.c: In function 'print_sym_table':
builtin-top.c:535: error: implicit declaration of function 'rb_for_each_entry' builtin-top.c:535: error: nested extern declaration of 'rb_for_each_entry' builtin-top.c:535: error: 'rb_node' undeclared (first use in this function) builtin-top.c:535: error: (Each undeclared identifier is reported only once builtin-top.c:535: error: for each function it appears in.) builtin-top.c:535: error: expected ';' before '{' token builtin-top.c:569: error: expected ';' before '{' token builtin-top.c:446: error: unused variable 'printed'
cc1: warnings being treated as errorsbuiltin-kmem.c: In function '__print_result':
builtin-kmem.c:364: error: implicit declaration of function 'rb_for_each_entry' builtin-kmem.c:364: error: nested extern declaration of 'rb_for_each_entry' builtin-kmem.c:364: error: 'node' undeclared (first use in this function) builtin-kmem.c:364: error: (Each undeclared identifier is reported only once builtin-kmem.c:364: error: for each function it appears in.) builtin-kmem.c:364: error: expected ';' before '{' token builtin-kmem.c:353: error: unused parameter 'session' builtin-kmem.c:354: error: unused parameter 'n_lines'
make: *** [builtin-kmem.o] Error 1
make: *** [builtin-top.o] Error 1
cc1: warnings being treated as errorsbuiltin-sched.c: In function '__cmd_lat':
builtin-sched.c:1719: error: implicit declaration of function 'rb_for_each_entry' builtin-sched.c:1719: error: nested extern declaration of 'rb_for_each_entry' builtin-sched.c:1719: error: 'node' undeclared (first use in this function) builtin-sched.c:1719: error: (Each undeclared identifier is reported only once builtin-sched.c:1719: error: for each function it appears in.) builtin-sched.c:1720: error: expected ';' before 'output_lat_thread'
make: *** [builtin-sched.o] Error 1
cc1: warnings being treated as errorsutil/symbol.c: In function 'symbols__sort_by_name':util/symbol.c:297: error: implicit declaration of function 'rb_for_each_entry' util/symbol.c:297: error: nested extern declaration of 'rb_for_each_entry' util/symbol.c:297: error: 'rb_node' undeclared (first use in this function) util/symbol.c:297: error: (Each undeclared identifier is reported only once util/symbol.c:297: error: for each function it appears in.) util/symbol.c:298: error: expected ';' before 'symbols__insert_by_name' util/symbol.c:292: error: unused parameter 'self'util/symbol.c: In function 'dso__fprintf':util/symbol.c:378: error: 'rb_node' undeclared (first use in this function) util/symbol.c:379: error: expected ';' before 'ret'util/symbol.c: In function 'map_groups__find_by_name':util/symbol.c:1342: error: 'rb_node' undeclared (first use in this function) util/symbol.c:1343: error: expected ';' before 'if' util/symbol.c:1337: error: unused parameter 'name'
make: *** [util/symbol.o] Error 1
rm .perf.dev.null
Ingo
Re: [PATCH 5/6] perf tools: Use rb_for_each_entry
Em Wed, Jan 13, 2010 at 10:11:35AM +0100, Ingo Molnar escreveu:
Quoted 21 lines · Arnaldo Carvalho de Melo
Quoted 8 lines
From: Arnaldo Carvalho de Melo <[email protected]>
Cc Fr??d??ric Weisbecker <[email protected]>Cc Mike Galbraith <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Paul Mackerras <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>Quoted 8 lines
--- tools/perf/builtin-annotate.c | 19 ++++++------------- tools/perf/builtin-diff.c | 5 ++--- tools/perf/builtin-kmem.c | 12 +++++------- tools/perf/builtin-sched.c | 10 ++-------- tools/perf/builtin-top.c | 10 +++------- tools/perf/util/symbol.c | 16 ++++++---------- 6 files changed, 24 insertions(+), 48 deletions(-)hm, this one doesnt build very well:
Quoted 10 lines
touch .perf.dev.null
CC builtin-annotate.o
CC builtin-diff.o
CC builtin-sched.o
CC builtin-top.o
CC builtin-kmem.o
CCutil/symbol.o
cc1: warnings being treated as errorsbuiltin-diff.c: In function 'perf_session__match_hists':
builtin-diff.c:148: error: implicit declaration of function 'rb_for_each_entry'
Checking and will resend shortly.
- Arnaldo
PATCH 6/6 perf tools: Encode kernel module mappings in perf.data
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We were always looking at the running machine /proc/modules, even when processing a perf.data file, which only makes sense when we're doing 'perf record' and 'perf report' on the same machine, and in close sucession, or if we don't use modules at all, right Peter? ;-)
Now, at 'perf record' time we read /proc/modules, find the long path for modules, and put them as PERF_MMAP events, just like we did to encode the reloc reference symbol for vmlinux. Talking about that now it is encoded in .pgoff, so that we can use .{start,len} to store the address boundaries for the kernel so that when we reconstruct the kmaps tree we can do lookups right away, without having to fixup the end of the kernel maps like we did in the past (and now only in perf record).
One more step in the 'perf archive' direction when we'll finally be able to collect data in one machine and analyse in another.
--- tools/perf/builtin-kmem.c | 5 ++ tools/perf/builtin-record.c | 11 ++++ tools/perf/builtin-top.c | 5 ++ tools/perf/util/event.c | 104 ++++++++++++++++++++++++++++++++++----- tools/perf/util/event.h | 2 + tools/perf/util/session.c | 8 ++-- tools/perf/util/session.h | 4 ++ tools/perf/util/symbol.c | 116 +++++++++++++++++++++++++++++++------------ tools/perf/util/symbol.h | 3 + tools/perf/util/thread.h | 4 ++ 10 files changed, 214 insertions(+), 48 deletions(-)
tools/perf/builtin-kmem.c +5 -0
@@ -492,6 +492,11 @@ static int __cmd_kmem(void)if (!perf_session__has_traces (session,"kmem record" )) goto out_delete; +if (perf_session__create_kernel_maps (session) <0 ) { +pr_err ("Problems creating kernel maps\n" ); +return -1 ; + } +setup_pager (); err =perf_session__process_events (session, &event_ops);if (err !=0 )
tools/perf/builtin-record.c +11 -0
@@ -465,6 +465,11 @@ static int __cmd_record(int argc, const char **argv)return -1 ; } +if (perf_session__create_kernel_maps (session) <0 ) { +pr_err ("Problems creating kernel maps\n" ); +return -1 ; + } +if (!file_new) { err =perf_header__read (&session->header, output);if (err <0 )
@@ -558,6 +563,12 @@ static int __cmd_record(int argc, const char **argv)return err; } + err =event__synthesize_modules (process_synthesized_event, session); +if (err <0 ) { +pr_err ("Couldn't record kernel reference relocation symbol.\n" ); +return err; + } +if (!system_wide && profile_cpu ==-1 )event__synthesize_thread (pid, process_synthesized_event, session);
tools/perf/builtin-top.c +5 -0
@@ -1161,6 +1161,11 @@ static int __cmd_top(void)if (session ==NULL )return -ENOMEM ; +if (perf_session__create_kernel_maps (session) <0 ) { +pr_err ("Problems creating kernel maps\n" ); +return -1 ; + } +if (target_pid !=-1 )event__synthesize_thread (target_pid, event__process, session);else
tools/perf/util/event.c +92 -12
135 lines not on this page · raw message
tools/perf/util/event.h +2 -0
@@ -112,6 +112,8 @@ void event__synthesize_threads(event__handler_t process,int event__synthesize_kernel_mmap (event__handler_t process,struct perf_session *session,const char *symbol_name); +int event__synthesize_modules (event__handler_t process, +struct perf_session *session);int event__process_comm (event_t *self,struct perf_session *session);int event__process_lost (event_t *self,struct perf_session *session);
tools/perf/util/session.c +4 -4
@@ -69,9 +69,6 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc self->unknown_events =0 ;map_groups__init (&self->kmaps); -if (perf_session__create_kernel_maps (self) <0 ) - goto out_delete; -if (mode ==O_RDONLY &&perf_session__open (self, force) <0 ) goto out_delete;
@@ -268,8 +265,11 @@ int perf_header__read_build_ids(int input, u64 offset, u64 size) head = &dsos__kernel; dso =__dsos__findnew (head, filename); -if (dso !=NULL ) +if (dso !=NULL ) {dso__set_build_id (dso, &bev.build_id); +if (head == &dsos__kernel && filename[0 ] =='[' ) + dso->kernel =1 ; + } offset += bev.header.size; }
tools/perf/util/session.h +4 -0
@@ -69,4 +69,8 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,void perf_session__reloc_vmlinux_maps (struct perf_session *self,u64 unrelocated_addr); +#define perf_session__for_each_module_map (self, pos, nd) \ + rb_for_each_entry(pos, nd, &self->kmaps.maps[MAP__FUNCTION], rb_node) \ + if (pos->dso->kernel) continue; else +#endif /* __PERF_SESSION_H */
tools/perf/util/symbol.c +84 -32
200 lines not on this page · raw message
tools/perf/util/symbol.h +3 -0
@@ -134,6 +134,7 @@ size_t dsos__fprintf_buildid(FILE *fp);size_t dso__fprintf_buildid (struct dso *self,FILE *fp);size_t dso__fprintf (struct dso *self,enum map_type type,FILE *fp);char dso__symtab_origin (const struct dso *self); +void dso__set_long_name (struct dso *self,char *name);void dso__set_build_id (struct dso *self,void *build_id);struct symbol *dso__find_symbol (struct dso *self,enum map_type type,u64 addr); struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
@@ -151,5 +152,7 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);int perf_session__create_kernel_maps (struct perf_session *self); +struct map *perf_session__new_module_map (struct perf_session *self,u64 start, +const char *filename);extern struct dso *vdso;#endif /* __PERF_SYMBOL */
tools/perf/util/thread.h +4 -0
@@ -67,4 +67,8 @@ map_groups__find_function(struct map_groups *self, struct perf_session *session,struct map *map_groups__find_by_name (struct map_groups *self,enum map_type type,const char *name); + +int __map_groups__create_kernel_maps (struct map_groups *self, +struct map *vmlinux_maps[MAP__NR_TYPES ], +struct dso *kernel);#endif /* __PERF_THREAD_H */
Signature · 1 line
1.6.2.5