]> www.infradead.org Git - nvme.git/commit
drivers/perf: riscv: Do not update the event data if uptodate
authorAtish Patra <atishp@rivosinc.com>
Fri, 28 Jun 2024 07:51:41 +0000 (00:51 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 3 Jul 2024 19:56:15 +0000 (12:56 -0700)
commita3f24e83d11d7ceb4743416c803332e9c5749298
tree444d4bbe6d512e85cff79e23437bdd2f1e520706
parent1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
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: a8625217a054 ("drivers/perf: riscv: Implement SBI PMU snapshot function")
Closes:https://lore.kernel.org/all/CC51D53B-846C-4D81-86FC-FBF969D0A0D6@pku.edu.cn/

Reported-by: garthlei@pku.edu.cn
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20240628-misc_perf_fixes-v4-1-e01cfddcf035@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
drivers/perf/riscv_pmu.c