diff options
-rw-r--r-- | arch/x86/events/intel/core.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index cb8522290e6a..86138267b68a 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c | |||
@@ -2110,6 +2110,27 @@ again: | |||
2110 | GLOBAL_STATUS_LBRS_FROZEN); | 2110 | GLOBAL_STATUS_LBRS_FROZEN); |
2111 | if (!status) | 2111 | if (!status) |
2112 | goto done; | 2112 | goto done; |
2113 | /* | ||
2114 | * In case multiple PEBS events are sampled at the same time, | ||
2115 | * it is possible to have GLOBAL_STATUS bit 62 set indicating | ||
2116 | * PEBS buffer overflow and also seeing at most 3 PEBS counters | ||
2117 | * having their bits set in the status register. This is a sign | ||
2118 | * that there was at least one PEBS record pending at the time | ||
2119 | * of the PMU interrupt. PEBS counters must only be processed | ||
2120 | * via the drain_pebs() calls and not via the regular sample | ||
2121 | * processing loop coming after that the function, otherwise | ||
2122 | * phony regular samples may be generated in the sampling buffer | ||
2123 | * not marked with the EXACT tag. Another possibility is to have | ||
2124 | * one PEBS event and at least one non-PEBS event whic hoverflows | ||
2125 | * while PEBS has armed. In this case, bit 62 of GLOBAL_STATUS will | ||
2126 | * not be set, yet the overflow status bit for the PEBS counter will | ||
2127 | * be on Skylake. | ||
2128 | * | ||
2129 | * To avoid this problem, we systematically ignore the PEBS-enabled | ||
2130 | * counters from the GLOBAL_STATUS mask and we always process PEBS | ||
2131 | * events via drain_pebs(). | ||
2132 | */ | ||
2133 | status &= ~cpuc->pebs_enabled; | ||
2113 | 2134 | ||
2114 | /* | 2135 | /* |
2115 | * PEBS overflow sets bit 62 in the global status register | 2136 | * PEBS overflow sets bit 62 in the global status register |
@@ -2117,15 +2138,6 @@ again: | |||
2117 | if (__test_and_clear_bit(62, (unsigned long *)&status)) { | 2138 | if (__test_and_clear_bit(62, (unsigned long *)&status)) { |
2118 | handled++; | 2139 | handled++; |
2119 | x86_pmu.drain_pebs(regs); | 2140 | x86_pmu.drain_pebs(regs); |
2120 | /* | ||
2121 | * There are cases where, even though, the PEBS ovfl bit is set | ||
2122 | * in GLOBAL_OVF_STATUS, the PEBS events may also have their | ||
2123 | * overflow bits set for their counters. We must clear them | ||
2124 | * here because they have been processed as exact samples in | ||
2125 | * the drain_pebs() routine. They must not be processed again | ||
2126 | * in the for_each_bit_set() loop for regular samples below. | ||
2127 | */ | ||
2128 | status &= ~cpuc->pebs_enabled; | ||
2129 | status &= x86_pmu.intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI; | 2141 | status &= x86_pmu.intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI; |
2130 | } | 2142 | } |
2131 | 2143 | ||