All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] perf tools: Return first evsel for non-sample event on old kernel
@ 2012-01-31  1:15 Namhyung Kim
  2012-01-31  1:15 ` [PATCH v2 2/2] perf: Add error message for EMFILE Namhyung Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2012-01-31  1:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-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 <acme@ghostprotocols.net>
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
---
 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 a6d50e376257..3ffb3203f335 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->entries.next, struct perf_evsel, node);
+
 	return NULL;
 }
 
-- 
1.7.9.rc1.dirty


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

end of thread, other threads:[~2012-01-31  1:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31  1:15 [PATCH v2 1/2] perf tools: Return first evsel for non-sample event on old kernel Namhyung Kim
2012-01-31  1:15 ` [PATCH v2 2/2] perf: Add error message for EMFILE Namhyung Kim
2012-01-31  1:30   ` Arnaldo Carvalho de Melo
2012-01-31  1:40     ` Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.