Adding simple read function that reads/store data into given struct perf_counts_values *count object.
Link: http://lkml.kernel.org/n/tip-9r2zmzq0vkw8l300usq82...@git.kernel.org Signed-off-by: Jiri Olsa <jo...@kernel.org> --- tools/perf/util/evsel.c | 14 ++++++++++++++ tools/perf/util/evsel.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1608e29ab83d..c1d210f8e799 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1060,6 +1060,20 @@ int perf_evsel__read_cb(struct perf_evsel *evsel, int cpu, int thread, return cb(evsel, cpu, thread, &count); } +int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, + struct perf_counts_values *count) +{ + memset(count, 0, sizeof(*count)); + + if (FD(evsel, cpu, thread) < 0) + return -EINVAL; + + if (readn(FD(evsel, cpu, thread), count, sizeof(*count)) < 0) + return -errno; + + return 0; +} + int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, int cpu, int thread, bool scale) { diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 80929965f0f5..9609df91abc1 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -275,6 +275,9 @@ typedef int (perf_evsel__read_cb_t)(struct perf_evsel *evsel, int perf_evsel__read_cb(struct perf_evsel *evsel, int cpu, int thread, perf_evsel__read_cb_t cb); +int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, + struct perf_counts_values *count); + int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, int cpu, int thread, bool scale); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/