Skip to content

Commit a3f24e8

Browse files
atishp04palmer-dabbelt
authored andcommitted
drivers/perf: riscv: Do not update the event data if uptodate
In case of an counter overflow, the event data may get corrupted if called from an external overflow handler. This happens because we can't update the counter without starting it when SBI PMU extension is in use. However, the prev_count has been already updated at the first pass while the counter value is still the old one. The solution is simple where we don't need to update it again if it is already updated which can be detected using hwc state. The event state in the overflow handler is updated in the following patch. Thus, this fix can't be backported to kernel version where overflow support was added. Fixes: a862521 ("drivers/perf: riscv: Implement SBI PMU snapshot function") Closes:https://lore.kernel.org/all/[email protected]/ Reported-by: [email protected] Signed-off-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1613e60 commit a3f24e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/perf/riscv_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ u64 riscv_pmu_event_update(struct perf_event *event)
167167
unsigned long cmask;
168168
u64 oldval, delta;
169169

170-
if (!rvpmu->ctr_read)
170+
if (!rvpmu->ctr_read || (hwc->state & PERF_HES_UPTODATE))
171171
return 0;
172172

173173
cmask = riscv_pmu_ctr_get_width_mask(event);

0 commit comments

Comments
 (0)