[lkml]   [2012]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[tip:perf/urgent] perf evlist: Return first evsel for non-sample event on old kernel
Commit-ID:  30e68bcc67e41ab6dab4e4e1efc7ea8ca893c0af
Author: Namhyung Kim <>
AuthorDate: Mon, 20 Feb 2012 10:47:26 +0900
Committer: Arnaldo Carvalho de Melo <>
CommitDate: Wed, 29 Feb 2012 18:29:44 -0300

perf evlist: Return first evsel for non-sample event on old kernel

On old kernels that don't support sample_id_all feature,
perf_evlist__id2evsel() returns NULL for non-sampling events.

This breaks perf top when multiple events are given on command line. Fix
it by using first evsel in the evlist. This will also prevent getting
the same (potential) problem in such new tool/ old kernel combo.

Suggested-by: Arnaldo Carvalho de Melo <>
Cc: Ingo Molnar <>
Cc: Paul Mackerras <>
Cc: Peter Zijlstra <>
Signed-off-by: Namhyung Kim <>
Signed-off-by: Arnaldo Carvalho de Melo <>
tools/perf/util/evlist.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 3f16e08..ea32a06 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -349,6 +349,10 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
hlist_for_each_entry(sid, pos, head, node)
if (sid->id == id)
return sid->evsel;
+ if (!perf_evlist__sample_id_all(evlist))
+ return list_entry(evlist->, struct perf_evsel, node);
return NULL;

 \ /
  Last update: 2012-03-02 10:53    [W:0.059 / U:1.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site