From: tip-bot for Stephane Eranian <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
eranian@google.com, mingo@kernel.org,
alexander.shishkin@linux.intel.com, stable@vger.kernel.org,
tglx@linutronix.de, torvalds@linux-foundation.org, hpa@zytor.com,
acme@redhat.com, jolsa@redhat.com, vincent.weaver@maine.edu
Subject: [tip:perf/core] perf/x86/pebs: Add workaround for broken OVFL status on HSW+
Date: Tue, 8 Mar 2016 05:16:31 -0800 [thread overview]
Message-ID: <tip-8077eca079a212f26419c57226f28696b7100683@git.kernel.org> (raw)
In-Reply-To: <1457034642-21837-3-git-send-email-eranian@google.com>
Commit-ID: 8077eca079a212f26419c57226f28696b7100683
Gitweb: http://git.kernel.org/tip/8077eca079a212f26419c57226f28696b7100683
Author: Stephane Eranian <eranian@google.com>
AuthorDate: Thu, 3 Mar 2016 20:50:41 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 8 Mar 2016 12:18:35 +0100
perf/x86/pebs: Add workaround for broken OVFL status on HSW+
This patch fixes an issue with the GLOBAL_OVERFLOW_STATUS bits on
Haswell, Broadwell and Skylake processors when using PEBS.
The SDM stipulates that when the PEBS iterrupt threshold is crossed,
an interrupt is posted and the kernel is interrupted. The kernel will
find GLOBAL_OVF_SATUS bit 62 set indicating there are PEBS records to
drain. But the bits corresponding to the actual counters should NOT be
set. The kernel follows the SDM and assumes that all PEBS events are
processed in the drain_pebs() callback. The kernel then checks for
remaining overflows on any other (non-PEBS) events and processes these
in the for_each_bit_set(&status) loop.
As it turns out, under certain conditions on HSW and later processors,
on PEBS buffer interrupt, bit 62 is set but the counter bits may be
set as well. In that case, the kernel drains PEBS and generates
SAMPLES with the EXACT tag, then it processes the counter bits, and
generates normal (non-EXACT) SAMPLES.
I ran into this problem by trying to understand why on HSW sampling on
a PEBS event was sometimes returning SAMPLES without the EXACT tag.
This should not happen on user level code because HSW has the
eventing_ip which always point to the instruction that caused the
event.
The workaround in this patch simply ensures that the bits for the
counters used for PEBS events are cleared after the PEBS buffer has
been drained. With this fix 100% of the PEBS samples on my user code
report the EXACT tag.
Before:
$ perf record -e cpu/event=0xd0,umask=0x81/upp ./multichase
$ perf report -D | fgrep SAMPLES
PERF_RECORD_SAMPLE(IP, 0x2): 11775/11775: 0x406de5 period: 73469 addr: 0 exact=Y
\--- EXACT tag is missing
After:
$ perf record -e cpu/event=0xd0,umask=0x81/upp ./multichase
$ perf report -D | fgrep SAMPLES
PERF_RECORD_SAMPLE(IP, 0x4002): 11775/11775: 0x406de5 period: 73469 addr: 0 exact=Y
\--- EXACT tag is set
The problem tends to appear more often when multiple PEBS events are used.
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: adrian.hunter@intel.com
Cc: kan.liang@intel.com
Cc: namhyung@kernel.org
Link: http://lkml.kernel.org/r/1457034642-21837-3-git-send-email-eranian@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/events/intel/core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index b3f6349..6567c62 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -1892,6 +1892,16 @@ again:
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;
}
/*
next prev parent reply other threads:[~2016-03-08 13:17 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 19:50 [PATCH 0/3] perf/x86/pebs: various important fixes for PEBS Stephane Eranian
2016-03-03 19:50 ` [PATCH 1/3] perf/x86/intel: add definition for PT PMI bit Stephane Eranian
2016-03-08 13:16 ` [tip:perf/core] perf/x86/intel: Add " tip-bot for Stephane Eranian
2016-03-03 19:50 ` [PATCH 2/3] perf/x86/pebs: add workaround for broken OVFL status on HSW Stephane Eranian
2016-03-03 21:43 ` Andi Kleen
2016-03-03 23:40 ` Stephane Eranian
2016-03-07 10:24 ` Peter Zijlstra
2016-03-07 12:18 ` Peter Zijlstra
2016-03-07 18:27 ` Jiri Olsa
2016-03-07 20:25 ` Peter Zijlstra
2016-03-08 20:59 ` Stephane Eranian
2016-03-08 21:07 ` Peter Zijlstra
2016-03-08 21:13 ` Stephane Eranian
2016-03-09 5:34 ` Stephane Eranian
2016-03-09 5:44 ` Stephane Eranian
2016-03-09 17:40 ` Stephane Eranian
2016-03-10 10:42 ` Peter Zijlstra
2016-12-14 17:55 ` Peter Zijlstra
2016-12-15 7:26 ` Stephane Eranian
2016-12-15 7:52 ` Jiri Olsa
2016-12-15 8:04 ` Stephane Eranian
2016-12-15 8:42 ` Peter Zijlstra
2016-12-15 16:59 ` Stephane Eranian
2016-12-15 17:10 ` Peter Zijlstra
2016-12-16 8:38 ` Stephane Eranian
2016-12-16 17:48 ` Stephane Eranian
2016-03-10 13:53 ` Peter Zijlstra
2016-03-10 16:10 ` Stephane Eranian
2016-03-08 13:16 ` tip-bot for Stephane Eranian [this message]
2016-03-03 19:50 ` [PATCH 3/3] perf/x86/pebs: add proper PEBS constraints for Broadwell Stephane Eranian
2016-03-08 13:16 ` [tip:perf/core] perf/x86/pebs: Add " tip-bot for Stephane Eranian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-8077eca079a212f26419c57226f28696b7100683@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vincent.weaver@maine.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox