perf/x86/pebs: catch all PEBS overflow conditions
Subsystems (2)
PATCH 1/1 perf/x86/pebs: catch all PEBS overflow conditions
This patch fixes an issue with the IRQ handler for the PMU when PEBS events are combined with non-PEBS events such as the NMI watchdog.
The setting of the OVF status register appears to be racy. In a situation with 1 non-PEBS and multiple PEBS events, if the non-PEBS counter overflows first, the handler may be entered showing a non-PEBS counter overflowed and possibly also a PEBS counter overflowed but without having bit 62 set. In that case the current handler is considering the overflow of the PEBS counter as general non-PEBS and this would result in a non-EXACT sample.
The fix is for PEBS to check if either bit 62 is set or if any of the active PEBS counters bits are set in the OVF status. Either one is a sign that there may be some samples to process via drain_pebs().
With this patch applied on top of peterz queue.tip perf/core, I do not see non-EXACT samples for PEBS events on Haswell and later.
--- arch/x86/events/intel/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/events/intel/core.c +7 -1
@@ -1831,8 +1831,11 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)/* * PEBS overflow sets bit 62 in the global status register +* This is racy with overflows of non-PEBS counters, so we +* status may not have bit 62 set yet pebs counters may have overflowed */ -if (__test_and_clear_bit (62 , (unsigned long *)&status)) { +if (__test_and_clear_bit (62 , (unsigned long *)&status) + || (status & cpuc->pebs_enabled)) { handled++; x86_pmu.drain_pebs (regs);/*
@@ -1845,6 +1848,9 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)*/ status &= ~cpuc->pebs_enabled; status &= x86_pmu.intel_ctrl |GLOBAL_STATUS_TRACE_TOPAPMI ; + +/* make sure bit 62 is acked in any case */ + orig_status |=1ULL <<62 ; }/*
Signature · 1 line
2.5.0
kbuild test robot
build botreproduce:
Hi Stephane,
[auto build test ERROR on next-20160310]
[cannot apply to tip/x86/core v4.5-rc7 v4.5-rc6 v4.5-rc5 v4.5-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stephane-Eranian/perf-x86-pebs-catch-all-PEBS-overflow-conditions/20160311-001126 config: i386-tinyconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
arch/x86/events//intel/core.c: In function 'intel_pmu_handle_irq':
>> arch/x86/events//intel/core.c:1910:3: error: 'orig_status' undeclared (first use in this function)
orig_status |= 1ULL << 62;
^arch/x86/events//intel/core.c:1910:3: note: each undeclared identifier is reported only once for each function it appears in
vim +/orig_status +1910 arch/x86/events//intel/core.c
1904 * in the for_each_bit_set() loop for regular samples below.
1905 */
1906 status &= ~cpuc->pebs_enabled;
1907 status &= x86_pmu.intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
1908
1909 /* make sure bit 62 is acked in any case */
> 1910 orig_status |= 1ULL << 62;
1911 }
1912
1913 /*
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation