perf evlist: Set the leader in the perf_evlist__config method

Since we need to ensure the leader is set before configuring the
evsel perf_event_attrs.

Reducing the boilerplate needed by tools, helping, for instance,
'perf trace', that wasn't setting the leader.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-22shm0ptkch2kgl7rtqlligx@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2012-12-10 16:41:31 -03:00
parent 62b807f649
commit f77a951826
5 changed files with 13 additions and 14 deletions

View file

@ -230,14 +230,7 @@ static int perf_record__open(struct perf_record *rec)
struct perf_record_opts *opts = &rec->opts; struct perf_record_opts *opts = &rec->opts;
int rc = 0; int rc = 0;
/* perf_evlist__config(evlist, opts);
* Set the evsel leader links before we configure attributes,
* since some might depend on this info.
*/
if (opts->group)
perf_evlist__set_leader(evlist);
perf_evlist__config_attrs(evlist, opts);
list_for_each_entry(pos, &evlist->entries, node) { list_for_each_entry(pos, &evlist->entries, node) {
struct perf_event_attr *attr = &pos->attr; struct perf_event_attr *attr = &pos->attr;

View file

@ -455,7 +455,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
goto out_delete_evlist; goto out_delete_evlist;
} }
perf_evlist__config_attrs(evlist, &trace->opts); perf_evlist__config(evlist, &trace->opts);
signal(SIGCHLD, sig_handler); signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);

View file

@ -106,7 +106,7 @@ int test__PERF_RECORD(void)
perf_evsel__set_sample_bit(evsel, CPU); perf_evsel__set_sample_bit(evsel, CPU);
perf_evsel__set_sample_bit(evsel, TID); perf_evsel__set_sample_bit(evsel, TID);
perf_evsel__set_sample_bit(evsel, TIME); perf_evsel__set_sample_bit(evsel, TIME);
perf_evlist__config_attrs(evlist, &opts); perf_evlist__config(evlist, &opts);
err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask);
if (err < 0) { if (err < 0) {

View file

@ -49,10 +49,16 @@ struct perf_evlist *perf_evlist__new(struct cpu_map *cpus,
return evlist; return evlist;
} }
void perf_evlist__config_attrs(struct perf_evlist *evlist, void perf_evlist__config(struct perf_evlist *evlist,
struct perf_record_opts *opts) struct perf_record_opts *opts)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
/*
* Set the evsel leader links before we configure attributes,
* since some might depend on this info.
*/
if (opts->group)
perf_evlist__set_leader(evlist);
if (evlist->cpus->map[0] < 0) if (evlist->cpus->map[0] < 0)
opts->no_inherit = true; opts->no_inherit = true;

View file

@ -76,8 +76,8 @@ union perf_event *perf_evlist__mmap_read(struct perf_evlist *self, int idx);
int perf_evlist__open(struct perf_evlist *evlist); int perf_evlist__open(struct perf_evlist *evlist);
void perf_evlist__config_attrs(struct perf_evlist *evlist, void perf_evlist__config(struct perf_evlist *evlist,
struct perf_record_opts *opts); struct perf_record_opts *opts);
int perf_evlist__prepare_workload(struct perf_evlist *evlist, int perf_evlist__prepare_workload(struct perf_evlist *evlist,
struct perf_record_opts *opts, struct perf_record_opts *opts,