diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-11-21 04:31:07 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-11-24 16:03:50 -0500 |
commit | 011dccbdd93b7022c5c67e7c55fa8b5030b5e03d (patch) | |
tree | 10e439cf503f6c6c30ace37f30c85201b0c0bd6a | |
parent | 13112bbf595d4081f291f7061bb096dbf4401d41 (diff) |
perf evsel: Introduce perf_evsel__read_cb function
Adding perf_evsel__read_cb read function that retuns count values via
callback. It will be used later in stat command as single way to
retrieve counter values.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
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/1416562275-12404-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/evsel.c | 16 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 7 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 6dc7a67e6d35..2d26b7ad6fe0 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -917,6 +917,22 @@ void perf_counts_values__scale(struct perf_counts_values *count, | |||
917 | *pscaled = scaled; | 917 | *pscaled = scaled; |
918 | } | 918 | } |
919 | 919 | ||
920 | int perf_evsel__read_cb(struct perf_evsel *evsel, int cpu, int thread, | ||
921 | perf_evsel__read_cb_t cb) | ||
922 | { | ||
923 | struct perf_counts_values count; | ||
924 | |||
925 | memset(&count, 0, sizeof(count)); | ||
926 | |||
927 | if (FD(evsel, cpu, thread) < 0) | ||
928 | return -EINVAL; | ||
929 | |||
930 | if (readn(FD(evsel, cpu, thread), &count, sizeof(count)) < 0) | ||
931 | return -errno; | ||
932 | |||
933 | return cb(evsel, cpu, thread, &count); | ||
934 | } | ||
935 | |||
920 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | 936 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, |
921 | int cpu, int thread, bool scale) | 937 | int cpu, int thread, bool scale) |
922 | { | 938 | { |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 7af0377ceb18..5c93bed8e8d9 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -233,6 +233,13 @@ static inline bool perf_evsel__match2(struct perf_evsel *e1, | |||
233 | (a)->attr.type == (b)->attr.type && \ | 233 | (a)->attr.type == (b)->attr.type && \ |
234 | (a)->attr.config == (b)->attr.config) | 234 | (a)->attr.config == (b)->attr.config) |
235 | 235 | ||
236 | typedef int (perf_evsel__read_cb_t)(struct perf_evsel *evsel, | ||
237 | int cpu, int thread, | ||
238 | struct perf_counts_values *count); | ||
239 | |||
240 | int perf_evsel__read_cb(struct perf_evsel *evsel, int cpu, int thread, | ||
241 | perf_evsel__read_cb_t cb); | ||
242 | |||
236 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | 243 | int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, |
237 | int cpu, int thread, bool scale); | 244 | int cpu, int thread, bool scale); |
238 | 245 | ||