From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>, Ingo Molnar <mingo@redhat.com>
Cc: linux-kernel@vger.kernel.org, vince@deater.net,
eranian@google.com, Arnaldo Carvalho de Melo <acme@infradead.org>,
Borislav Petkov <bp@suse.de>,
Thomas Gleixner <tglx@linutronix.de>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Subject: [PATCH 2/2] perf/x86/intel/pt: Fail event creation if VMX operation is on
Date: Tue, 14 Feb 2017 15:24:16 +0200 [thread overview]
Message-ID: <20170214132416.26400-3-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20170214132416.26400-1-alexander.shishkin@linux.intel.com>
On systems where PT does not coexist with VMX, users get confused when
PT turns up with no data because they forgot they're running a kvm
session at the same time.
This patch adds a preemptive check for any active VMX operations that
will fail event creation. This does not provide any guarantees or
protection against racing with a kvm starting in parallel, but is
intended to serve as a hint for the user. If VMXON happens after an
event had been created, the event will still produce an empty trace.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reported-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/events/intel/pt.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
index 9372fa4549..b1490a879c 100644
--- a/arch/x86/events/intel/pt.c
+++ b/arch/x86/events/intel/pt.c
@@ -1444,6 +1444,20 @@ static void pt_event_destroy(struct perf_event *event)
static int pt_event_init(struct perf_event *event)
{
+ int cpu, vmx_on = 0;
+
+ get_online_cpus();
+ for_each_online_cpu(cpu) {
+ struct pt *pt = per_cpu_ptr(&pt_ctx, cpu);
+
+ if (READ_ONCE(pt->vmx_on))
+ vmx_on++;
+ }
+ put_online_cpus();
+
+ if (vmx_on)
+ return -EBUSY;
+
if (event->attr.type != pt_pmu.pmu.type)
return -ENOENT;
--
2.11.0
next prev parent reply other threads:[~2017-02-14 13:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 13:24 [PATCH 0/2] perf/x86/intel/pt: VMX related updates Alexander Shishkin
2017-02-14 13:24 ` [PATCH 1/2] perf/x86/intel/pt: Fail event scheduling on conflict with VMX Alexander Shishkin
2017-02-14 13:56 ` Peter Zijlstra
2017-02-14 16:17 ` Alexander Shishkin
2017-02-14 16:27 ` Peter Zijlstra
2017-02-14 17:21 ` Alexander Shishkin
2017-02-14 18:38 ` Peter Zijlstra
2017-02-14 19:48 ` Peter Zijlstra
2017-02-15 8:11 ` Alexander Shishkin
2017-02-15 8:53 ` Peter Zijlstra
2017-02-14 13:24 ` Alexander Shishkin [this message]
2017-02-14 14:02 ` [PATCH 2/2] perf/x86/intel/pt: Fail event creation if VMX operation is on Peter Zijlstra
2017-02-14 17:47 ` Arnaldo Carvalho de Melo
2017-02-15 8:34 ` Alexander Shishkin
2017-02-15 8:56 ` Peter Zijlstra
2017-02-15 13:05 ` Alexander Shishkin
2017-02-15 13:12 ` Arnaldo Carvalho de Melo
2017-02-15 13:37 ` Peter Zijlstra
2017-02-15 12:51 ` Arnaldo Carvalho de Melo
2017-02-15 13:09 ` Alexander Shishkin
2017-02-15 13:16 ` Arnaldo Carvalho de Melo
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=20170214132416.26400-3-alexander.shishkin@linux.intel.com \
--to=alexander.shishkin@linux.intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=bp@suse.de \
--cc=eranian@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=vince@deater.net \
/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
Powered by JetHome