Skip to content

Commit afbef30

Browse files
Kan LiangIngo Molnar
authored andcommitted
perf/x86/intel: Set PERF_ATTACH_SCHED_CB for large PEBS and LBR
To supply a PID/TID for large PEBS, it requires flushing the PEBS buffer in a context switch. For normal LBRs, a context switch can flip the address space and LBR entries are not tagged with an identifier, we need to wipe the LBR, even for per-cpu events. For LBR callstack, save/restore the stack is required during a context switch. Set PERF_ATTACH_SCHED_CB for the event with large PEBS & LBR. Fixes: 9c964ef ("perf/x86/intel: Drain the PEBS buffer during context switches") Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a5398bf commit afbef30

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/events/intel/core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,8 +3662,10 @@ static int intel_pmu_hw_config(struct perf_event *event)
36623662
if (!(event->attr.freq || (event->attr.wakeup_events && !event->attr.watermark))) {
36633663
event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD;
36643664
if (!(event->attr.sample_type &
3665-
~intel_pmu_large_pebs_flags(event)))
3665+
~intel_pmu_large_pebs_flags(event))) {
36663666
event->hw.flags |= PERF_X86_EVENT_LARGE_PEBS;
3667+
event->attach_state |= PERF_ATTACH_SCHED_CB;
3668+
}
36673669
}
36683670
if (x86_pmu.pebs_aliases)
36693671
x86_pmu.pebs_aliases(event);
@@ -3676,6 +3678,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
36763678
ret = intel_pmu_setup_lbr_filter(event);
36773679
if (ret)
36783680
return ret;
3681+
event->attach_state |= PERF_ATTACH_SCHED_CB;
36793682

36803683
/*
36813684
* BTS is set up earlier in this path, so don't account twice

0 commit comments

Comments
 (0)