[PATCH v2 1/2] libperf: Add processing to scale the counters obtained during the read() system call when multiplexing
From: Shunsuke Nakamura
Date: Wed Sep 22 2021 - 06:17:11 EST
From: nakamura shunsuke <nakamura.shun@xxxxxxxxxxx>
perf_evsel__read() scales counters obtained by RDPMC during multiplexing, but
does not scale counters obtained by read() system call.
Add processing to perf_evsel__read() to scale the counters obtained during the
read() system call when multiplexing.
Signed-off-by: Shunsuke Nakamura <nakamura.shun@xxxxxxxxxxx>
---
tools/lib/perf/evsel.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/lib/perf/evsel.c b/tools/lib/perf/evsel.c
index 8441e3e1aaac..0ebd1d34436f 100644
--- a/tools/lib/perf/evsel.c
+++ b/tools/lib/perf/evsel.c
@@ -18,6 +18,7 @@
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <asm/bug.h>
+#include <linux/math64.h>
void perf_evsel__init(struct perf_evsel *evsel, struct perf_event_attr *attr,
int idx)
@@ -321,6 +322,11 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,
if (readn(*fd, count->values, size) <= 0)
return -errno;
+ if (count->ena != count->run) {
+ if (count->run != 0)
+ count->val = mul_u64_u64_div64(count->val, count->ena, count->run);
+ }
+
return 0;
}
--
2.27.0