Skip to content

Commit 2fe1bc1

Browse files
Andi KleenIngo Molnar
authored andcommitted
perf/x86: Enable free running PEBS for REGS_USER/INTR
[ Note, this is a Git cherry-pick of the following commit: a47ba4d ("perf/x86: Enable free running PEBS for REGS_USER/INTR") ... for easier x86 PTI code testing and back-porting. ] Currently free running PEBS is disabled when user or interrupt registers are requested. Most of the registers are actually available in the PEBS record and can be supported. So we just need to check for the supported registers and then allow it: it is all except for the segment register. For user registers this only works when the counter is limited to ring 3 only, so this also needs to be checked. Signed-off-by: Andi Kleen <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f2dbad3 commit 2fe1bc1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

arch/x86/events/intel/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,10 @@ static unsigned long intel_pmu_free_running_flags(struct perf_event *event)
29582958

29592959
if (event->attr.use_clockid)
29602960
flags &= ~PERF_SAMPLE_TIME;
2961+
if (!event->attr.exclude_kernel)
2962+
flags &= ~PERF_SAMPLE_REGS_USER;
2963+
if (event->attr.sample_regs_user & ~PEBS_REGS)
2964+
flags &= ~(PERF_SAMPLE_REGS_USER | PERF_SAMPLE_REGS_INTR);
29612965
return flags;
29622966
}
29632967

arch/x86/events/perf_event.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ struct amd_nb {
8585
* Flags PEBS can handle without an PMI.
8686
*
8787
* TID can only be handled by flushing at context switch.
88+
* REGS_USER can be handled for events limited to ring 3.
8889
*
8990
*/
9091
#define PEBS_FREERUNNING_FLAGS \
9192
(PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_ADDR | \
9293
PERF_SAMPLE_ID | PERF_SAMPLE_CPU | PERF_SAMPLE_STREAM_ID | \
9394
PERF_SAMPLE_DATA_SRC | PERF_SAMPLE_IDENTIFIER | \
94-
PERF_SAMPLE_TRANSACTION | PERF_SAMPLE_PHYS_ADDR)
95+
PERF_SAMPLE_TRANSACTION | PERF_SAMPLE_PHYS_ADDR | \
96+
PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER)
9597

9698
/*
9799
* A debug store configuration.
@@ -110,6 +112,26 @@ struct debug_store {
110112
u64 pebs_event_reset[MAX_PEBS_EVENTS];
111113
};
112114

115+
#define PEBS_REGS \
116+
(PERF_REG_X86_AX | \
117+
PERF_REG_X86_BX | \
118+
PERF_REG_X86_CX | \
119+
PERF_REG_X86_DX | \
120+
PERF_REG_X86_DI | \
121+
PERF_REG_X86_SI | \
122+
PERF_REG_X86_SP | \
123+
PERF_REG_X86_BP | \
124+
PERF_REG_X86_IP | \
125+
PERF_REG_X86_FLAGS | \
126+
PERF_REG_X86_R8 | \
127+
PERF_REG_X86_R9 | \
128+
PERF_REG_X86_R10 | \
129+
PERF_REG_X86_R11 | \
130+
PERF_REG_X86_R12 | \
131+
PERF_REG_X86_R13 | \
132+
PERF_REG_X86_R14 | \
133+
PERF_REG_X86_R15)
134+
113135
/*
114136
* Per register state.
115137
*/

0 commit comments

Comments
 (0)