Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1354997

Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status on HSW

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status on HSW
Date 2016-03-10 11:50 +0100
Message-ID <rb6kh-5OL-7@gated-at.bofh.it> (permalink)
References (5 earlier) <rax3c-6qY-9@gated-at.bofh.it> <raxcR-6uj-5@gated-at.bofh.it> <raF0L-3nW-37@gated-at.bofh.it> <raFaq-3s0-19@gated-at.bofh.it> <raQpc-2UT-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Mar 09, 2016 at 09:40:07AM -0800, Stephane Eranian wrote:
> With your queue.tip perf/core branch, I run into another problem.
> I am monitoring with 2 PEBS events and I have the NMI watchdog enabled.
> 
> I see non-EXACT PEBS records again, despite my change (which is in).
> I tracked it down to the following issue after the testing of bit 62:
> 
> [31137.273061] CPU71 status=0x200000001 orig_status=0x200000001 bit62=0
> 
> The IRQ handler is called because the fixed counter for the NMI has overflowed
> and it sees this in bit 33, but it also sees that one of the PEBS
> events has also
> overflowed, yet bit 62 is not set. Therefore both overflows are
> treated as regular
> and the drain_pebs() is not called generating a non-EXACT record for the PEBS
> counter (counter 0). So something is wrong still and this is on Broadwell.
> 
> First, I don't understand why the OVF bit for counter 0 is set. It
> should not according
> to specs because the counter is in PEBS mode. There must be a race there. So we
> have to handle it by relying on cpuc->pebs_enabled. I will try that.
> We likely also
> need to force OVF bit 62 to 1 so we can ack it in the end (and in case
> it gets set).

How about we make the clear of pebs_enabled unconditional?

---
 arch/x86/events/intel/core.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index 68fa55b4d42e..dc9579665425 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -1883,6 +1883,16 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
 	status &= ~(GLOBAL_STATUS_COND_CHG |
 		    GLOBAL_STATUS_ASIF |
 		    GLOBAL_STATUS_LBRS_FROZEN);
+	/*
+	 * There are cases where, even though, the PEBS ovfl bit is set
+	 * in GLOBAL_OVF_STATUS, the PEBS events may also have their
+	 * overflow bits set for their counters. We must clear them
+	 * here because they have been processed as exact samples in
+	 * the drain_pebs() routine. They must not be processed again
+	 * in the for_each_bit_set() loop for regular samples below.
+	 */
+	status &= ~cpuc->pebs_enabled;
+
 	if (!status)
 		goto done;
 
@@ -1892,16 +1902,6 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
 	if (__test_and_clear_bit(62, (unsigned long *)&status)) {
 		handled++;
 		x86_pmu.drain_pebs(regs);
-		/*
-		 * There are cases where, even though, the PEBS ovfl bit is set
-		 * in GLOBAL_OVF_STATUS, the PEBS events may also have their
-		 * overflow bits set for their counters. We must clear them
-		 * here because they have been processed as exact samples in
-		 * the drain_pebs() routine. They must not be processed again
-		 * in the for_each_bit_set() loop for regular samples below.
-		 */
-		status &= ~cpuc->pebs_enabled;
-		status &= x86_pmu.intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI;
 	}
 
 	/*

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-07 11:30 +0100
  Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-07 13:20 +0100
    Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Jiri Olsa <jolsa@redhat.com> - 2016-03-07 19:30 +0100
      Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-07 21:30 +0100
        Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-08 22:10 +0100
          Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-08 22:10 +0100
            Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-08 22:20 +0100
              Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-09 06:40 +0100
                Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-09 06:50 +0100
                Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-09 18:50 +0100
                Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-10 11:50 +0100
    Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Peter Zijlstra <peterz@infradead.org> - 2016-03-10 15:00 +0100
      Re: [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status  on HSW Stephane Eranian <eranian@google.com> - 2016-03-10 17:20 +0100

csiph-web