[PATCH 3/3] powerpc/perf: Update prev_count of event to get accurate values
From: Gautam Menghani
Date: Tue Aug 11 2026 - 10:12:29 EST
When vpa_pmu_read() is called twice while a process is running on a cpu,
the "event->hw.prev_count" variable returns a stale value on the 2nd
read which results in a larger value getting added to event->count.
Fix this by updating the event->hw.prev_count every time vpa_pmu_read()
is called.
Signed-off-by: Gautam Menghani <gautam@xxxxxxxxxxxxx>
---
arch/powerpc/perf/vpa-pmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/perf/vpa-pmu.c b/arch/powerpc/perf/vpa-pmu.c
index 334ef7719db9..f5cfa4d5e369 100644
--- a/arch/powerpc/perf/vpa-pmu.c
+++ b/arch/powerpc/perf/vpa-pmu.c
@@ -145,6 +145,7 @@ static void vpa_pmu_read(struct perf_event *event)
final_data = new_data - prev_data;
local64_add(final_data, &event->count);
+ local64_set(&event->hw.prev_count, new_data);
}
static void vpa_pmu_del(struct perf_event *event, int flags)
--
2.54.0