perf auxtrace: Automatically group aux-output events
Adrian Hunter
reviewerPATCH 1/1 perf auxtrace: Automatically group aux-output events
aux-output events need to have an AUX area event as the group leader. However, grouping events does not allow the AUX area event to be given an address filter because the --filter option must come after the event, which conflicts with the grouping syntax.
To allow filtering in that case, automatically create a group since that is the requirement anyway.
Example: (requires Intel Tremont)
perf record -c 500 -e 'intel_pt//u' --filter 'filter main @ /bin/ls' -e 'cycles/aux-output/pp' ls
--- tools/perf/builtin-record.c | 2 ++ tools/perf/util/auxtrace.c | 15 +++++++++++++++ tools/perf/util/auxtrace.h | 6 ++++++ 3 files changed, 23 insertions(+)
tools/perf/builtin-record.c +2 -0
@@ -731,6 +731,8 @@ static int record__auxtrace_init(struct record *rec)if (err)return err; +auxtrace_regroup_aux_output (rec->evlist); +return auxtrace_parse_filters (rec->evlist); }
tools/perf/util/auxtrace.c +15 -0
@@ -788,6 +788,21 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr,return auxtrace_validate_aux_sample_size (evlist, opts); } +void auxtrace_regroup_aux_output (struct evlist *evlist) +{ +struct evsel *evsel, *aux_evsel =NULL ; +struct evsel_config_term *term; + +evlist__for_each_entry (evlist, evsel) { +if (evsel__is_aux_event (evsel)) + aux_evsel = evsel; + term =evsel__get_config_term (evsel,AUX_OUTPUT ); +/* If possible, group with the AUX event */ +if (term && aux_evsel) +evlist__regroup (evlist, aux_evsel, evsel); + } +} +struct auxtrace_record *__weak auxtrace_record__init (struct evlist *evlist__maybe_unused ,int *err) {
tools/perf/util/auxtrace.h +6 -0
@@ -559,6 +559,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,int auxtrace_parse_sample_options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts,const char *str); +void auxtrace_regroup_aux_output (struct evlist *evlist);int auxtrace_record__options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts);
@@ -740,6 +741,11 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr __maybe_unused,return -EINVAL ; } +static inline +void auxtrace_regroup_aux_output (struct evlist *evlist__maybe_unused ) +{ +} + static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused,
Signature · 1 line
2.17.1
Quoted 11 lines · Adrian Hunter
aux-output events need to have an AUX area event as the group leader. However, grouping events does not allow the AUX area event to be given an address filter because the --filter option must come after the event, which conflicts with the grouping syntax.
To allow filtering in that case, automatically create a group since that is the requirement anyway.
Example: (requires Intel Tremont)
perf record -c 500 -e 'intel_pt//u' --filter 'filter main @ /bin/ls' -e 'cycles/aux-output/pp' ls
great, nice to see this working
jirka
Quoted 74 lines
Signed-off-by Adrian Hunter <[email protected]>--- tools/perf/builtin-record.c | 2 ++ tools/perf/util/auxtrace.c | 15 +++++++++++++++ tools/perf/util/auxtrace.h | 6 ++++++ 3 files changed, 23 insertions(+)tools/perf/builtin-record.c +2
-0@@ -731,6 +731,8 @@ static int record__auxtrace_init(struct record *rec)if (err)return err; +auxtrace_regroup_aux_output (rec->evlist); +return auxtrace_parse_filters (rec->evlist); }tools/perf/util/auxtrace.c +15
-0@@ -788,6 +788,21 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr,return auxtrace_validate_aux_sample_size (evlist, opts); } +void auxtrace_regroup_aux_output (struct evlist *evlist) +{ +struct evsel *evsel, *aux_evsel =NULL ; +struct evsel_config_term *term; + +evlist__for_each_entry (evlist, evsel) { +if (evsel__is_aux_event (evsel)) + aux_evsel = evsel; + term =evsel__get_config_term (evsel,AUX_OUTPUT ); +/* If possible, group with the AUX event */ +if (term && aux_evsel) +evlist__regroup (evlist, aux_evsel, evsel); + } +} +struct auxtrace_record *__weak auxtrace_record__init (struct evlist *evlist__maybe_unused ,int *err) {tools/perf/util/auxtrace.h +6
-0@@ -559,6 +559,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,int auxtrace_parse_sample_options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts,const char *str); +void auxtrace_regroup_aux_output (struct evlist *evlist);int auxtrace_record__options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts);@@ -740,6 +741,11 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr __maybe_unused,return -EINVAL ; } +static inline +void auxtrace_regroup_aux_output (struct evlist *evlist__maybe_unused ) +{ +} + static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused,Signature · 1 line
2.17.1
Em Sun, Jan 24, 2021 at 12:11:25AM +0100, Jiri Olsa escreveu:
Quoted 6 lines · Adrian Hunter
Quoted 5 lines
aux-output events need to have an AUX area event as the group leader. However, grouping events does not allow the AUX area event to be given an address filter because the --filter option must come after the event, which conflicts with the grouping syntax.
Quoted 8 lines
Quoted 6 lines
To allow filtering in that case, automatically create a group since that is the requirement anyway.
Example: (requires Intel Tremont)
perf record -c 500 -e 'intel_pt//u' --filter 'filter main @ /bin/ls' -e 'cycles/aux-output/pp' lsgreat, nice to see this working
Thanks, applied.
- Arnaldo
Quoted 77 lines
jirka
Quoted 74 lines
Signed-off-by Adrian Hunter <[email protected]>--- tools/perf/builtin-record.c | 2 ++ tools/perf/util/auxtrace.c | 15 +++++++++++++++ tools/perf/util/auxtrace.h | 6 ++++++ 3 files changed, 23 insertions(+)tools/perf/builtin-record.c +2
-0@@ -731,6 +731,8 @@ static int record__auxtrace_init(struct record *rec)if (err)return err; +auxtrace_regroup_aux_output (rec->evlist); +return auxtrace_parse_filters (rec->evlist); }tools/perf/util/auxtrace.c +15
-0@@ -788,6 +788,21 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr,return auxtrace_validate_aux_sample_size (evlist, opts); } +void auxtrace_regroup_aux_output (struct evlist *evlist) +{ +struct evsel *evsel, *aux_evsel =NULL ; +struct evsel_config_term *term; + +evlist__for_each_entry (evlist, evsel) { +if (evsel__is_aux_event (evsel)) + aux_evsel = evsel; + term =evsel__get_config_term (evsel,AUX_OUTPUT ); +/* If possible, group with the AUX event */ +if (term && aux_evsel) +evlist__regroup (evlist, aux_evsel, evsel); + } +} +struct auxtrace_record *__weak auxtrace_record__init (struct evlist *evlist__maybe_unused ,int *err) {tools/perf/util/auxtrace.h +6
-0@@ -559,6 +559,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr,int auxtrace_parse_sample_options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts,const char *str); +void auxtrace_regroup_aux_output (struct evlist *evlist);int auxtrace_record__options (struct auxtrace_record *itr,struct evlist *evlist,struct record_opts *opts);@@ -740,6 +741,11 @@ int auxtrace_parse_sample_options(struct auxtrace_record *itr __maybe_unused,return -EINVAL ; } +static inline +void auxtrace_regroup_aux_output (struct evlist *evlist__maybe_unused ) +{ +} + static inline int auxtrace__process_event(struct perf_session *session __maybe_unused, union perf_event *event __maybe_unused,Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo