]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt
authorRavi Bangoria <ravi.bangoria@amd.com>
Wed, 15 Jan 2025 05:44:33 +0000 (05:44 +0000)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 3 Feb 2025 10:46:05 +0000 (11:46 +0100)
commit46dcf85566170d4528b842bf83ffc350d71771fa
tree2fecb65d62afac5bc1ce29b501b570dbb4a19b0c
parent598bdf4fefff5af4ce6d26d16f7b2a20808fc4cb
perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt

IBS Op uses two counters: MaxCnt and CurCnt. MaxCnt is programmed with
the desired sample period. IBS hw generates sample when CurCnt reaches
to MaxCnt. The size of these counter used to be 20 bits but later they
were extended to 27 bits. The 7 bit extension is indicated by CPUID
Fn8000_001B_EAX[6 / OpCntExt].

perf_ibs->cnt_mask variable contains bit masks for MaxCnt and CurCnt.
But IBS driver does not set upper 7 bits of CurCnt in cnt_mask even
when OpCntExt CPUID bit is set. Fix this.

IBS driver uses cnt_mask[CurCnt] bits only while disabling an event.
Fortunately, CurCnt bits are not read from MSR while re-enabling the
event, instead MaxCnt is programmed with desired period and CurCnt is
set to 0. Hence, we did not see any issues so far.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/r/20250115054438.1021-5-ravi.bangoria@amd.com
arch/x86/events/amd/ibs.c
arch/x86/include/asm/perf_event.h