linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf auxtrace: Automatically group aux-output events
@ 2021-01-21 14:04 Adrian Hunter
  2021-01-23 23:11 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2021-01-21 14:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa; +Cc: linux-kernel

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

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/builtin-record.c |  2 ++
 tools/perf/util/auxtrace.c  | 15 +++++++++++++++
 tools/perf/util/auxtrace.h  |  6 ++++++
 3 files changed, 23 insertions(+)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 8a0127d4fb52..687f1449a845 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -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);
 }
 
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index a60878498139..953f4afacd3b 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -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)
 {
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 7e5c9e1552bd..a4fbb33b7245 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -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,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf auxtrace: Automatically group aux-output events
  2021-01-21 14:04 [PATCH] perf auxtrace: Automatically group aux-output events Adrian Hunter
@ 2021-01-23 23:11 ` Jiri Olsa
  2021-02-18 19:11   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2021-01-23 23:11 UTC (permalink / raw)
  To: Adrian Hunter; +Cc: Arnaldo Carvalho de Melo, linux-kernel

On Thu, Jan 21, 2021 at 04:04:18PM +0200, Adrian Hunter wrote:
> 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

> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/builtin-record.c |  2 ++
>  tools/perf/util/auxtrace.c  | 15 +++++++++++++++
>  tools/perf/util/auxtrace.h  |  6 ++++++
>  3 files changed, 23 insertions(+)
> 
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 8a0127d4fb52..687f1449a845 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -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);
>  }
>  
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index a60878498139..953f4afacd3b 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -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)
>  {
> diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
> index 7e5c9e1552bd..a4fbb33b7245 100644
> --- a/tools/perf/util/auxtrace.h
> +++ b/tools/perf/util/auxtrace.h
> @@ -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,
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf auxtrace: Automatically group aux-output events
  2021-01-23 23:11 ` Jiri Olsa
@ 2021-02-18 19:11   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-02-18 19:11 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: Adrian Hunter, linux-kernel

Em Sun, Jan 24, 2021 at 12:11:25AM +0100, Jiri Olsa escreveu:
> On Thu, Jan 21, 2021 at 04:04:18PM +0200, Adrian Hunter wrote:
> > 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

Thanks, applied.

- Arnaldo

 
> jirka
> 
> > 
> > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> > ---
> >  tools/perf/builtin-record.c |  2 ++
> >  tools/perf/util/auxtrace.c  | 15 +++++++++++++++
> >  tools/perf/util/auxtrace.h  |  6 ++++++
> >  3 files changed, 23 insertions(+)
> > 
> > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> > index 8a0127d4fb52..687f1449a845 100644
> > --- a/tools/perf/builtin-record.c
> > +++ b/tools/perf/builtin-record.c
> > @@ -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);
> >  }
> >  
> > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> > index a60878498139..953f4afacd3b 100644
> > --- a/tools/perf/util/auxtrace.c
> > +++ b/tools/perf/util/auxtrace.c
> > @@ -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)
> >  {
> > diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
> > index 7e5c9e1552bd..a4fbb33b7245 100644
> > --- a/tools/perf/util/auxtrace.h
> > +++ b/tools/perf/util/auxtrace.h
> > @@ -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,
> > -- 
> > 2.17.1
> > 
> 

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-18 19:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 14:04 [PATCH] perf auxtrace: Automatically group aux-output events Adrian Hunter
2021-01-23 23:11 ` Jiri Olsa
2021-02-18 19:11   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).