perf evlist: Add perf_evlist__id2evsel_strict()
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 25 Sep 2015 13:15:52 +0000 (16:15 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 28 Sep 2015 20:11:00 +0000 (17:11 -0300)
perf_evlist__id2evsel_strict() is the same as perf_evlist__id2evsel()
except that it ensures that the id must match.

This will be used by perf inject to find a specific evsel that is to be
deleted, hence the need to match exactly.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1443186956-18718-22-git-send-email-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 a8643735dcea8ede082b87ef054606320b8e9900..e6760380d73151f01bb49f710cd05d0ba851ece3 100644 (file)
@@ -617,6 +617,21 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id)
        return NULL;
 }
 
+struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
+                                               u64 id)
+{
+       struct perf_sample_id *sid;
+
+       if (!id)
+               return NULL;
+
+       sid = perf_evlist__id2sid(evlist, id);
+       if (sid)
+               return sid->evsel;
+
+       return NULL;
+}
+
 static int perf_evlist__event2id(struct perf_evlist *evlist,
                                 union perf_event *event, u64 *id)
 {
index 115d8b53c6010a5a1d466b04535245d9fd8f8579..0edf0d4f4efa8a3831021a3f8d7e35d91c97369d 100644 (file)
@@ -104,6 +104,8 @@ int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mas
 int perf_evlist__poll(struct perf_evlist *evlist, int timeout);
 
 struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id);
+struct perf_evsel *perf_evlist__id2evsel_strict(struct perf_evlist *evlist,
+                                               u64 id);
 
 struct perf_sample_id *perf_evlist__id2sid(struct perf_evlist *evlist, u64 id);