Add multiple event support to perf report
cover Add multiple event support to perf report
Currently perf report is unable to handle multiple events even though perf record is capable of capturing such a stream. For instance if we run 'perf record -e dtlb-misses -e cache-misses sleep 5'
today and then ask report to show the results we get:
# Samples: 18866
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. ......
#
47.52% sleep [kernel.kallsyms] [k] page_fault
32.93% sleep [kernel.kallsyms] [k] locks_remove_posix
8.52% sleep [kernel.kallsyms] [k] acl_permission_check
3.46% sleep [kernel.kallsyms] [k] __wake_up_bit
3.31% sleep [kernel.kallsyms] [k] vfs_read
3.23% sleep [kernel.kallsyms] [k] kmem_cache_alloc
0.56% sleep [kernel.kallsyms] [k] get_page_from_freelist
0.15% sleep [kernel.kallsyms] [k] pipe_read
0.13% sleep [kernel.kallsyms] [k] pipe_lock_nested
0.13% sleep [kernel.kallsyms] [k] mm_alloc
0.06% sleep [kernel.kallsyms] [k] mm_init#
# (For a higher level overview, try: perf report --sort comm,dso) #
Worse than only reporting on one of the events, perf report has summed the two events. i.e. There is no distinguishing between dtlb-misses and cache-misses.
This set of patches addresses this problem and now when perf report is run with the same event stream that produced the above report, the output is this:
# Samples: 8620 cache-misses
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. ......
#
72.06% sleep [kernel.kallsyms] [k] locks_remove_posix
18.64% sleep [kernel.kallsyms] [k] acl_permission_check
7.56% sleep [kernel.kallsyms] [k] __wake_up_bit
1.22% sleep [kernel.kallsyms] [k] get_page_from_freelist
0.34% sleep [kernel.kallsyms] [k] pipe_read
0.13% sleep [kernel.kallsyms] [k] mm_init
0.02% sleep [kernel.kallsyms] [k] pipe_lock_nested
0.01% sleep [kernel.kallsyms] [k] mm_alloc
0.01% sleep [kernel.kallsyms] [k] kmem_cache_alloc# Samples: 10246 dTLB-load-misses
#
# Overhead Command Shared Object Symbol
# ........ ....... ................. ......
#
87.51% sleep [kernel.kallsyms] [k] page_fault
6.10% sleep [kernel.kallsyms] [k] vfs_read
5.94% sleep [kernel.kallsyms] [k] kmem_cache_alloc
0.22% sleep [kernel.kallsyms] [k] mm_alloc
0.22% sleep [kernel.kallsyms] [k] pipe_lock_nested#
# (For a higher level overview, try: perf report --sort comm,dso) #
Eric B Munson (5):
Add ID and STREAM_ID to recorded event data
Change add_hist_entry to take the tree root instead of session Add storage for seperating event types in report Change perf_session post processing functions to take hist tree Add multiple event support to perf report
tools/perf/builtin-annotate.c | 6 +- tools/perf/builtin-diff.c | 12 +++-- tools/perf/builtin-record.c | 3 +- tools/perf/builtin-report.c | 104 ++++++++++++++++++++++++++++++++++++----- tools/perf/util/event.h | 9 ++++ tools/perf/util/hist.c | 45 +++++++++--------- tools/perf/util/hist.h | 12 +++-- tools/perf/util/session.c | 1 + tools/perf/util/session.h | 1 + 9 files changed, 145 insertions(+), 48 deletions(-)
PATCH 5/5 Add multiple event support to perf report
In reply to Eric B MunsonPerf report does not handle multiple events being recorded even though perf record stores them properly on disk. This patch addresses that issue by adding the logic to perf report to use the event stream id that is saved by record and the new data structures to seperate the event streams and report them individually.
--- tools/perf/builtin-report.c | 105 +++++++++++++++++++++++++++++++++++++----- 1 files changed, 92 insertions(+), 13 deletions(-)
tools/perf/builtin-report.c +92 -13
@@ -45,29 +45,71 @@ static char *pretty_printing_style = default_pretty_printing_style;static char callchain_default_opt[] ="fractal,0.5" ; +static struct event_stat_id *get_stats (struct perf_session *self,u64 event_stream, +u32 type,u64 config) +{ +struct rb_node **p = &self->stats_by_id.rb_node; +struct rb_node *parent =NULL ; +struct event_stat_id *iter, *new; + +while (*p !=NULL ) { + parent = *p; + iter = rb_entry(parent, struct event_stat_id, rb_node); +if (iter->config == config) { +return iter; + } + +if (config > iter->config) + p = &(*p)->rb_right; +else + p = &(*p)->rb_left; + } + + new =malloc (sizeof (struct event_stat_id )); +if (new ==NULL ) +return NULL ; +memset (new,0 ,sizeof (struct event_stat_id )); + new->event_stream = event_stream; + new->config = config; + new->type = type; +rb_link_node (&new->rb_node, parent, p); +rb_insert_color (&new->rb_node, &self->stats_by_id); +return new; +} +static int perf_session__add_hist_entry (struct perf_session *self,struct addr_location *al, -struct ip_callchain *chain,u64 count) +struct sample_data *data) {struct symbol **syms =NULL , *parent =NULL ;bool hit;struct hist_entry *he; +struct event_stat_id *stats; +struct perf_event_attr *attr; -if ((sort__has_parent || symbol_conf.use_callchain) && chain) +if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain) syms =perf_session__resolve_callchain (self, al->thread, - chain, &parent); - he =__perf_session__add_hist_entry (&self->hists, al, parent, - count, &hit); + data->callchain, &parent); + + attr =perf_header__find_attr (data->id, &self->header); +if (attr) + stats =get_stats (self, data->id, attr->type, attr->config); +else + stats =get_stats (self, data->id,0 ,0 ); +if (stats ==NULL ) +return -ENOMEM ; + he =__perf_session__add_hist_entry (&stats->hists, al, parent, + data->period, &hit);if (he ==NULL )return -ENOMEM ;if (hit) - he->count += count; + he->count += data->period;if (symbol_conf.use_callchain) {if (!hit)callchain_init (&he->callchain); -append_chain (&he->callchain, chain, syms); +append_chain (&he->callchain, data->callchain, syms);free (syms); }
@@ -87,10 +129,29 @@ static int validate_chain(struct ip_callchain *chain, event_t *event)return 0 ; } +static int add_event_total (struct perf_session *session,struct sample_data *data, +struct perf_event_attr *attr) +{ +struct event_stat_id *stats; + +if (attr) + stats =get_stats (session, data->id, attr->type, attr->config); +else + stats =get_stats (session, data->id,0 ,0 ); + +if (!stats) +return -ENOMEM ; + + stats->stats.total += data->period; + session->events_stats.total += data->period; +return 0 ; +} +static int process_sample_event (event_t *event,struct perf_session *session) {struct sample_data data = { .period =1 , };struct addr_location al; +struct perf_event_attr *attr;event__parse_sample (event, session->sample_type, &data);
@@ -124,12 +185,18 @@ static int process_sample_event(event_t *event, struct perf_session *session)if (al.filtered || (hide_unresolved && al.sym ==NULL ))return 0 ; -if (perf_session__add_hist_entry (session, &al, data.callchain, data.period)) { +if (perf_session__add_hist_entry (session, &al, &data)) {pr_debug ("problem incrementing symbol count, skipping event\n" );return -1 ; } - session->events_stats.total += data.period; + attr =perf_header__find_attr (data.id, &session->header); + +if (add_event_total (session, &data, attr)) { +pr_debug ("problem adding event count\n" ); +return -1 ; + } +return 0 ; }
@@ -198,6 +265,7 @@ static int __cmd_report(void) {int ret = -EINVAL ;struct perf_session *session; +struct rb_node *next; session =perf_session__new (input_name,O_RDONLY , force);if (session ==NULL )
@@ -225,10 +293,21 @@ static int __cmd_report(void)if (verbose >2 )dsos__fprintf (stdout); -perf_session__collapse_resort (session); -perf_session__output_resort (session, session->events_stats.total); -fprintf (stdout,"# Samples: %Ld\n#\n" , session->events_stats.total); -perf_session__fprintf_hists (session,NULL , false, stdout); + next =rb_first (&session->stats_by_id); +while (next) { +struct event_stat_id *stats =rb_entry (next, + struct event_stat_id, + rb_node); +perf_session__collapse_resort (&stats->hists); +perf_session__output_resort (&stats->hists, stats->stats.total); +fprintf (stdout,"# Samples: %Ld %s\n#\n" , stats->stats.total, +__event_name (stats->type, stats->config)); +perf_session__fprintf_hists (&stats->hists,NULL , false, stdout, + stats->stats.total); +fprintf (stdout,"\n\n" ); + next =rb_next (&stats->rb_node); + } +if (sort_order == default_sort_order && parent_pattern == default_parent_pattern)fprintf (stdout,"#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n" );
Signature · 1 line
1.6.3.3
PATCH 4/5 Change perf_session post processing functions to take histogram tree
In reply to Eric B MunsonNow that report can store historgrams for multiple events we need to be able to do the post processing work for each histogram. This patch changes the post processing functions so that they can be called individually for each event's histogram.
--- tools/perf/builtin-annotate.c | 4 ++-- tools/perf/builtin-diff.c | 9 +++++---- tools/perf/util/hist.c | 39 ++++++++++++++++++++------------------- tools/perf/util/hist.h | 9 +++++---- 4 files changed, 32 insertions(+), 29 deletions(-)
tools/perf/builtin-annotate.c +2 -2
@@ -564,8 +564,8 @@ static int __cmd_annotate(void)if (verbose >2 )dsos__fprintf (stdout); -perf_session__collapse_resort (session); -perf_session__output_resort (session, session->event_total[0 ]); +perf_session__collapse_resort (&session->hists); +perf_session__output_resort (&session->hists, session->event_total[0 ]);perf_session__find_annotations (session); out_delete:perf_session__delete (session);
tools/perf/builtin-diff.c +5 -4
@@ -115,7 +115,7 @@ static void perf_session__resort_hist_entries(struct perf_session *self)static void perf_session__set_hist_entries_positions (struct perf_session *self) { -perf_session__output_resort (self, self->events_stats.total); +perf_session__output_resort (&self->hists, self->events_stats.total);perf_session__resort_hist_entries (self); }
@@ -167,13 +167,14 @@ static int __cmd_diff(void) goto out_delete; } -perf_session__output_resort (session[1 ], session[1 ]->events_stats.total); +perf_session__output_resort (&(session[1 ]->hists), session[1 ]->events_stats.total);if (show_displacement)perf_session__set_hist_entries_positions (session[0 ]);perf_session__match_hists (session[0 ], session[1 ]); -perf_session__fprintf_hists (session[1 ], session[0 ], - show_displacement, stdout); +perf_session__fprintf_hists (&(session[1 ]->hists), session[0 ], + show_displacement, stdout, + session[1 ]->events_stats.total); out_delete:for (i =0 ; i <2 ; ++i)perf_session__delete (session[i]);
tools/perf/util/hist.c +20 -19
@@ -130,7 +130,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)rb_insert_color (&he->rb_node, root); } -void perf_session__collapse_resort (struct perf_session *self) +void perf_session__collapse_resort (struct rb_root *hists) {struct rb_root tmp;struct rb_node *next;
@@ -140,17 +140,17 @@ void perf_session__collapse_resort(struct perf_session *self)return ; tmp =RB_ROOT ; - next =rb_first (&self->hists); + next =rb_first (hists);while (next) { n = rb_entry(next, struct hist_entry, rb_node); next =rb_next (&n->rb_node); -rb_erase (&n->rb_node, &self->hists); +rb_erase (&n->rb_node, hists);collapse__insert_entry (&tmp, n); } - self->hists = tmp; + *hists = tmp; }/*
@@ -183,7 +183,7 @@ static void perf_session__insert_output_hist_entry(struct rb_root *root,rb_insert_color (&he->rb_node, root); } -void perf_session__output_resort (struct perf_session *self,u64 total_samples) +void perf_session__output_resort (struct rb_root *hists,u64 total_samples) {struct rb_root tmp;struct rb_node *next;
@@ -194,18 +194,18 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples) total_samples * (callchain_param.min_percent /100 ); tmp =RB_ROOT ; - next =rb_first (&self->hists); + next =rb_first (hists);while (next) { n = rb_entry(next, struct hist_entry, rb_node); next =rb_next (&n->rb_node); -rb_erase (&n->rb_node, &self->hists); +rb_erase (&n->rb_node, hists);perf_session__insert_output_hist_entry (&tmp, n, min_callchain_hits); } - self->hists = tmp; + *hists = tmp; }static size_t callchain__fprintf_left_margin (FILE *fp,int left_margin)
@@ -456,10 +456,10 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self, }static size_t hist_entry__fprintf (struct hist_entry *self, -struct perf_session *session,struct perf_session *pair_session,bool show_displacement, -long displacement,FILE *fp) +long displacement,FILE *fp, +u64 session_total) {struct sort_entry *se;u64 count, total;
@@ -474,7 +474,7 @@ static size_t hist_entry__fprintf(struct hist_entry *self, total = pair_session->events_stats.total; }else { count = self->count; - total = session->events_stats.total; + total = session_total; }if (total)
@@ -496,8 +496,8 @@ static size_t hist_entry__fprintf(struct hist_entry *self,if (total >0 ) old_percent = (count *100.0 ) / total; -if (session->events_stats.total >0 ) - new_percent = (self->count *100.0 ) / session->events_stats.total; +if (session_total >0 ) + new_percent = (self->count *100.0 ) / session_total; diff = new_percent - old_percent;
@@ -544,16 +544,17 @@ static size_t hist_entry__fprintf(struct hist_entry *self, left_margin -=thread__comm_len (self->thread); } -hist_entry_callchain__fprintf (fp, self, session->events_stats.total, +hist_entry_callchain__fprintf (fp, self, session_total, left_margin); }return ret; } -size_t perf_session__fprintf_hists (struct perf_session *self, +size_t perf_session__fprintf_hists (struct rb_root *hists,struct perf_session *pair, -bool show_displacement,FILE *fp) +bool show_displacement,FILE *fp, +u64 session_total) {struct sort_entry *se;struct rb_node *nd;
@@ -641,7 +642,7 @@ size_t perf_session__fprintf_hists(struct perf_session *self,fprintf (fp,"\n#\n" ); print_entries: -for (nd =rb_first (&self->hists); nd; nd =rb_next (nd)) { +for (nd =rb_first (hists); nd; nd =rb_next (nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);if (show_displacement) {
@@ -652,8 +653,8 @@ print_entries: displacement =0 ; ++position; } - ret +=hist_entry__fprintf (h, self, pair, show_displacement, - displacement, fp); + ret +=hist_entry__fprintf (h, pair, show_displacement, + displacement, fp, session_total); }free (rem_sq_bracket);
tools/perf/util/hist.h +5 -4
@@ -20,9 +20,10 @@ extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);extern int64_t hist_entry__collapse (struct hist_entry *,struct hist_entry *);void hist_entry__free (struct hist_entry *); -void perf_session__output_resort (struct perf_session *self,u64 total_samples); -void perf_session__collapse_resort (struct perf_session *self); -size_t perf_session__fprintf_hists (struct perf_session *self, +void perf_session__output_resort (struct rb_root *hists,u64 total_samples); +void perf_session__collapse_resort (struct rb_root *hists); +size_t perf_session__fprintf_hists (struct rb_root *hists,struct perf_session *pair, -bool show_displacement,FILE *fp); +bool show_displacement,FILE *fp, +u64 session_total);#endif /* __PERF_HIST_H */
Signature · 1 line
1.6.3.3
PATCH 2/5 Change add_hist_entry to take the tree root instead of session
In reply to Eric B MunsonIn order to minimize the impact of storing multiple events in a report this function will now take the root of the histogram tree so that the logic for selecting the proper tree can be inserted before the call.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-diff.c | 3 ++- tools/perf/builtin-report.c | 3 ++- tools/perf/util/hist.c | 6 +++--- tools/perf/util/hist.h | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,return 0 ; } - he =__perf_session__add_hist_entry (self, al,NULL , count, &hit); + he =__perf_session__add_hist_entry (&self->hists, al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
tools/perf/builtin-diff.c +2 -1
@@ -26,7 +26,8 @@ static int perf_session__add_hist_entry(struct perf_session *self, struct addr_location *al, u64 count) { bool hit; -struct hist_entry *he =__perf_session__add_hist_entry (self, al,NULL , +struct hist_entry *he =__perf_session__add_hist_entry (&self->hists, + al,NULL , count, &hit);if (he ==NULL )return -ENOMEM ;
tools/perf/builtin-report.c +2 -1
@@ -56,7 +56,8 @@ static int perf_session__add_hist_entry(struct perf_session *self,if ((sort__has_parent || symbol_conf.use_callchain) && chain) syms =perf_session__resolve_callchain (self, al->thread, chain, &parent); - he =__perf_session__add_hist_entry (self, al, parent, count, &hit); + he =__perf_session__add_hist_entry (&self->hists, al, parent, + count, &hit);if (he ==NULL )return -ENOMEM ;
tools/perf/util/hist.c +3 -3
@@ -12,12 +12,12 @@ struct callchain_param callchain_param = {* histogram, sorted on item, collects counts */ -struct hist_entry *__perf_session__add_hist_entry (struct perf_session *self, +struct hist_entry *__perf_session__add_hist_entry (struct rb_root *hists,struct addr_location *al,struct symbol *sym_parent,u64 count,bool *hit) { -struct rb_node **p = &self->hists.rb_node; +struct rb_node **p = &hists->rb_node;struct rb_node *parent =NULL ;struct hist_entry *he;struct hist_entry entry = {
@@ -53,7 +53,7 @@ struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self,return NULL ; *he = entry;rb_link_node (&he->rb_node, parent, p); -rb_insert_color (&he->rb_node, &self->hists); +rb_insert_color (&he->rb_node, hists); *hit = false;return he; }
tools/perf/util/hist.h +2 -1
@@ -10,8 +10,9 @@ struct perf_session;struct hist_entry ;struct addr_location ;struct symbol ; +struct rb_root ; -struct hist_entry *__perf_session__add_hist_entry (struct perf_session *self, +struct hist_entry *__perf_session__add_hist_entry (struct rb_root *hists,struct addr_location *al,struct symbol *parent,u64 count,bool *hit);
Signature · 1 line
1.6.3.3
PATCH 1/5 Add ID and STREAM_ID to recorded event data
In reply to Eric B MunsonCurrently perf record does not write the ID or the STREAM_ID to disk for events. This doesn't allow report to tell if an event stream contains one or more types of events. This patch adds these two entries to the list of data that record will write to disk.
--- tools/perf/builtin-record.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
tools/perf/builtin-record.c +2 -1
@@ -242,7 +242,8 @@ static void create_counter(int counter, int cpu, pid_t pid)PERF_FORMAT_TOTAL_TIME_RUNNING |PERF_FORMAT_ID ; - attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; + attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | +PERF_SAMPLE_ID |PERF_SAMPLE_STREAM_ID ;if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ;
Signature · 1 line
1.6.3.3
PATCH 3/5 Add storage for seperating event types in report
In reply to Eric B MunsonThis patch adds the structures necessary to count each event type independently in perf report.
--- tools/perf/util/event.h | 9 +++++++++ tools/perf/util/session.c | 1 + tools/perf/util/session.h | 1 + 3 files changed, 11 insertions(+), 0 deletions(-)
tools/perf/util/event.h +9 -0
@@ -99,6 +99,15 @@ struct events_stats {u64 lost; }; +struct event_stat_id { +struct rb_node rb_node; +struct rb_root hists; +struct events_stats stats; +u64 config; +u64 event_stream; +u32 type; +}; +void event__print_totals (void );struct perf_session ;
tools/perf/util/session.c +1 -0
@@ -70,6 +70,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forcmemcpy (self->filename, filename, len); self->threads =RB_ROOT ; + self->stats_by_id =RB_ROOT ; self->last_match =NULL ; self->mmap_window =32 ; self->cwd =NULL ;
tools/perf/util/session.h +1 -0
@@ -20,6 +20,7 @@ struct perf_session {struct thread *last_match;struct map *vmlinux_maps[MAP__NR_TYPES ];struct events_stats events_stats; +struct rb_root stats_by_id;unsigned long event_total[PERF_RECORD_MAX ];unsigned long unknown_events;struct rb_root hists;
Signature · 1 line
1.6.3.3
Peter Zijlstra
maintainerRe: [PATCH 1/5] Add ID and STREAM_ID to recorded event data
In reply to Eric B MunsonQuoted 15 lines · Eric B Munson
Currently perf record does not write the ID or the
STREAM_IDto disk for events. This doesn't allow report to tell if an event stream contains one or more types of events. This patch adds these two entries to the list of data that record will write to disk.Signed-off-by Eric B Munson <[email protected]>--- tools/perf/builtin-record.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)tools/perf/builtin-record.c +0
-0
tools/perf/builtin-record.c static void create_counter(int counter, int cpu, pid_t pid) · line 249
Quoted 9 lines
tools/perf/builtin-record.c +2
-1@@ -242,7 +242,8 @@ static void create_counter(int counter, int cpu, pid_t pid)PERF_FORMAT_TOTAL_TIME_RUNNING |PERF_FORMAT_ID ; - attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; + attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | +PERF_SAMPLE_ID |PERF_SAMPLE_STREAM_ID ;if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ;
can we make this conditional on there being more than one event, that saves a little space/time when recording
Re: [PATCH 1/5] Add ID and STREAM_ID to recorded event data
Quoted 23 lines · Peter Zijlstra
Quoted 22 lines · Eric B Munson
Currently perf record does not write the ID or the
STREAM_IDto disk for events. This doesn't allow report to tell if an event stream contains one or more types of events. This patch adds these two entries to the list of data that record will write to disk.Signed-off-by Eric B Munson <[email protected]>--- tools/perf/builtin-record.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)tools/perf/builtin-record.c +2
-1@@ -242,7 +242,8 @@ static void create_counter(int counter, int cpu, pid_t pid)PERF_FORMAT_TOTAL_TIME_RUNNING |PERF_FORMAT_ID ; - attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; + attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | +PERF_SAMPLE_ID |PERF_SAMPLE_STREAM_ID ;
Quoted 6 lines
tools/perf/builtin-record.c static void create_counter(int counter, int cpu, pid_t pid) · line 249
Quoted 2 lines
tools/perf/builtin-record.c +0
-0if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ;can we make this conditional on there being more than one event, that saves a little space/time when recording
Yeah, I will add that in the next version.
Signature · 3 lines
Eric B Munson IBM Linux Technology Center [email protected]
Re: [PATCH 1/5] Add ID and STREAM_ID to recorded event data
In reply to Peter ZijlstraQuoted 23 lines · Peter Zijlstra
Quoted 22 lines · Eric B Munson
Currently perf record does not write the ID or the
STREAM_IDto disk for events. This doesn't allow report to tell if an event stream contains one or more types of events. This patch adds these two entries to the list of data that record will write to disk.Signed-off-by Eric B Munson <[email protected]>--- tools/perf/builtin-record.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)tools/perf/builtin-record.c +2
-1@@ -242,7 +242,8 @@ static void create_counter(int counter, int cpu, pid_t pid)PERF_FORMAT_TOTAL_TIME_RUNNING |PERF_FORMAT_ID ; - attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; + attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | +PERF_SAMPLE_ID |PERF_SAMPLE_STREAM_ID ;
Quoted 6 lines
tools/perf/builtin-record.c static void create_counter(int counter, int cpu, pid_t pid) · line 249
Quoted 2 lines
tools/perf/builtin-record.c +0
-0if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ;can we make this conditional on there being more than one event, that saves a little space/time when recording
The downside to this is report cannot print the name of the event being monitored if we do not record the sample and stream id. This is as report behaves currently and if that is okay then I will put out V2 with that included today.
Signature · 3 lines
Eric B Munson IBM Linux Technology Center [email protected]
Peter Zijlstra
maintainerRe: [PATCH 1/5] Add ID and STREAM_ID to recorded event data
Quoted 32 lines · Eric B Munson
Quoted 23 lines · Peter Zijlstra
Quoted 22 lines · Eric B Munson
Currently perf record does not write the ID or the
STREAM_IDto disk for events. This doesn't allow report to tell if an event stream contains one or more types of events. This patch adds these two entries to the list of data that record will write to disk.Signed-off-by Eric B Munson <[email protected]>--- tools/perf/builtin-record.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)tools/perf/builtin-record.c +2
-1@@ -242,7 +242,8 @@ static void create_counter(int counter, int cpu, pid_t pid)PERF_FORMAT_TOTAL_TIME_RUNNING |PERF_FORMAT_ID ; - attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID ; + attr->sample_type |=PERF_SAMPLE_IP |PERF_SAMPLE_TID | +PERF_SAMPLE_ID |PERF_SAMPLE_STREAM_ID ;Quoted 6 lines
tools/perf/builtin-record.c static void create_counter(int counter, int cpu, pid_t pid) · line 249
Quoted 2 lines
tools/perf/builtin-record.c +0
-0if (freq) { attr->sample_type |=PERF_SAMPLE_PERIOD ;can we make this conditional on there being more than one event, that saves a little space/time when recording
Quoted 3 lines
The downside to this is report cannot print the name of the event being monitored if we do not record the sample and stream id. This is as report behaves currently and if that is okay then I will put out V2 with that included today.
Well, if there's only one event, its clear what name to use, and if there's more than one event, we will include the ID.
BTW, I think you can do without the STREAM_ID, since that is only used to account throttled state iirc, and we don't actually do that.