Re: [tip:perf/urgent] perf evlist: Open event on evsel cpus and threads

From: Adrian Hunter
Date: Thu Sep 03 2015 - 12:23:51 EST

On 3/09/2015 6:27 p.m., Arnaldo Carvalho de Melo wrote:
Em Thu, Sep 03, 2015 at 04:34:24PM +0300, Adrian Hunter escreveu:
On 01/09/15 11:31, tip-bot for Kan Liang wrote:
Commit-ID: d988d5ee647861706bc7a391ddbc29429b50f00e
Author: Kan Liang <kan.liang@xxxxxxxxx>
AuthorDate: Fri, 21 Aug 2015 02:23:14 -0400
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 31 Aug 2015 17:28:01 -0300

perf evlist: Open event on evsel cpus and threads

An evsel may have different cpus and threads than the evlist it is in.

Use it's own cpus and threads, when opening the evsel in 'perf record'.

Signed-off-by: Kan Liang <kan.liang@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Just noticed this breaks Intel PT. Will have to investigate further.

What kind of breakage?

Can't open the sched_switch event

It all should be equivalent to before, its just that it uses
evsel->{threads,cpus} while before it was using evlist->{threads,cpus},
but that should point to the same thing if that
perf_evlist__propagate_maps() method was called, so I assume this is
some segfault?

I think maybe it doesn't consider evsels added later

Something we could catch in a 'test' entry? Even if that required Intel
PT hardware that would be something important to have, all this stuff is
growing in complexity, we need those tests...

There is "Test tracking with sched_switch" but you need to expose it
to the same issue i.e.

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d51a520..6aeffdd 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1433,7 +1433,7 @@ int perf_evlist__open(struct perf_evlist *evlist)

evlist__for_each(evlist, evsel) {
- err = perf_evsel__open(evsel, evlist->cpus, evlist->threads);
+ err = perf_evsel__open(evsel, evsel->cpus, evsel->threads);
if (err < 0)
goto out_err;

- Arnaldo

tools/perf/builtin-record.c | 2 +-
tools/perf/util/evlist.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a660022..1d14f38 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -279,7 +279,7 @@ static int record__open(struct record *rec)

evlist__for_each(evlist, pos) {
- if (perf_evsel__open(pos, evlist->cpus, evlist->threads) < 0) {
+ if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
if (verbose)
ui__warning("%s\n", msg);
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 8d00039..d51a520 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1181,6 +1181,10 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
if (evsel->filter == NULL)

+ /*
+ * filters only work for tracepoint event, which doesn't have cpu limit.
+ * So evlist and evsel should always be same.
+ */
err = perf_evsel__apply_filter(evsel, ncpus, nthreads, evsel->filter);
if (err) {
*err_evsel = evsel;

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at