[PATCH v0 24/71] perf evlist: Add perf_evlist__set_tracking_event()

From: Alexander Shishkin
Date: Wed Dec 11 2013 - 07:39:52 EST


From: Adrian Hunter <adrian.hunter@xxxxxxxxx>

Add a function to change which event is used
to track mmap, comm and task events.

This is needed with Instruction Tracing
because the Instruction Tracing event
must come first but cannot be used for
tracking because it will be disabled
under some circumstances.

Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
tools/perf/util/evlist.c | 20 ++++++++++++++++++++
tools/perf/util/evlist.h | 3 ++-
2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 93683bc..ae9cbe6 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1233,3 +1233,23 @@ void perf_evlist__to_front(struct perf_evlist *evlist,

list_splice(&move, &evlist->entries);
}
+
+int perf_evlist__set_tracking_event(struct perf_evlist *evlist,
+ struct perf_evsel *tracking_evsel)
+{
+ struct perf_evsel *evsel;
+
+ if (tracking_evsel->idx == 0)
+ return 0;
+
+ if (tracking_evsel->leader->nr_members > 1)
+ return -EINVAL;
+
+ list_for_each_entry(evsel, &evlist->entries, node) {
+ if (evsel->idx < tracking_evsel->idx)
+ evsel->idx += 1;
+ }
+ tracking_evsel->idx = 0;
+
+ return 0;
+}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 9f64ede..2c8d068 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -196,6 +196,7 @@ 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);
-
+int perf_evlist__set_tracking_event(struct perf_evlist *evlist,
+ struct perf_evsel *tracking_evsel);

#endif /* __PERF_EVLIST_H */
--
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/