perf evlist: Add perf_evlist__to_front()
authorAdrian Hunter <adrian.hunter@intel.com>
Wed, 11 Dec 2013 12:36:35 +0000 (14:36 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 13 Dec 2013 13:30:21 +0000 (10:30 -0300)
Add a function to move a selected event to the
front of the list.

This is needed because it is not possible
to use the PERF_EVENT_IOC_SET_OUTPUT IOCTL
from an Instruction Tracing event to a
non-Instruction Tracing event.  Thus the
Instruction Tracing event must come first.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.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 <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1386765443-26966-24-git-send-email-alexander.shishkin@linux.intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evlist.c
tools/perf/util/evlist.h

index 2eb7378e4c4064e657be6c39cb4119bcb29c82a3..0b31cee34874d2c5c152f886a7b1de8b3fc08bb0 100644 (file)
@@ -1212,3 +1212,20 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused,
 
        return 0;
 }
+
+void perf_evlist__to_front(struct perf_evlist *evlist,
+                          struct perf_evsel *move_evsel)
+{
+       struct perf_evsel *evsel, *n;
+       LIST_HEAD(move);
+
+       if (move_evsel == perf_evlist__first(evlist))
+               return;
+
+       list_for_each_entry_safe(evsel, n, &evlist->entries, node) {
+               if (evsel->leader == move_evsel->leader)
+                       list_move_tail(&evsel->node, &move);
+       }
+
+       list_splice(&move, &evlist->entries);
+}
index 8a04aae95a18f77639af65e85952a3e03329281c..9f64ede3ecbdd347b8f4a5cf7f816cd2baff93a9 100644 (file)
@@ -194,5 +194,8 @@ static inline void perf_mmap__write_tail(struct perf_mmap *md,
 }
 
 bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str);
+void perf_evlist__to_front(struct perf_evlist *evlist,
+                          struct perf_evsel *move_evsel);
+
 
 #endif /* __PERF_EVLIST_H */