diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index cd6ce7066f85c6c6905b82dcadc8acaf4263bcbc..2e0a4e064f44c48a34707ace191644d6118af658 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -955,6 +955,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 020f7e13634a186247a44720534892b2627e8783..a79944a21e8feda9698d02ee5503fcf32f806b5d 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -236,6 +236,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);