Skip to content

Commit 6fafd8d

Browse files
Ravi BangoriaSasha Levin
authored andcommitted
perf/amd/ibs: Fix perf_ibs_op.cnt_mask for CurCnt
[ Upstream commit 46dcf85 ] 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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 803eae3 commit 6fafd8d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/x86/events/amd/ibs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,8 @@ static __init int perf_ibs_op_init(void)
12221222
if (ibs_caps & IBS_CAPS_OPCNTEXT) {
12231223
perf_ibs_op.max_period |= IBS_OP_MAX_CNT_EXT_MASK;
12241224
perf_ibs_op.config_mask |= IBS_OP_MAX_CNT_EXT_MASK;
1225-
perf_ibs_op.cnt_mask |= IBS_OP_MAX_CNT_EXT_MASK;
1225+
perf_ibs_op.cnt_mask |= (IBS_OP_MAX_CNT_EXT_MASK |
1226+
IBS_OP_CUR_CNT_EXT_MASK);
12261227
}
12271228

12281229
if (ibs_caps & IBS_CAPS_ZEN4)

arch/x86/include/asm/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ struct pebs_xmm {
520520
*/
521521
#define IBS_OP_CUR_CNT (0xFFF80ULL<<32)
522522
#define IBS_OP_CUR_CNT_RAND (0x0007FULL<<32)
523+
#define IBS_OP_CUR_CNT_EXT_MASK (0x7FULL<<52)
523524
#define IBS_OP_CNT_CTL (1ULL<<19)
524525
#define IBS_OP_VAL (1ULL<<18)
525526
#define IBS_OP_ENABLE (1ULL<<17)

0 commit comments

Comments
 (0)