]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
perf auxtrace: Automatically group aux-output events
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 21 Jan 2021 14:04:18 +0000 (16:04 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 18 Feb 2021 19:11:19 +0000 (16:11 -0300)
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>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20210121140418.14705-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-record.c
tools/perf/util/auxtrace.c
tools/perf/util/auxtrace.h

index 29abc04007eb0d2deb58462f77fe7ff7d1684104..35465d1db6dda3ae171bc4a18260e44f2c8ce64c 100644 (file)
@@ -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);
 }
 
index a60878498139956c6cf070de6eafed8629307987..953f4afacd3b5d2cdf9e53c5990cdf2a6bf42c76 100644 (file)
@@ -788,6 +788,21 @@ no_opt:
        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)
 {
index 7e5c9e1552bd4abfa6420b9547c96b9b557cdc9e..a4fbb33b72452eab33a6dd46680ba1b3fad1f50a 100644 (file)
@@ -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,