From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH] perf/x86/intel/pt: Don't die on VMXON Date: Wed, 6 Apr 2016 10:52:27 +0200 Message-ID: <20160406085227.GO3448@twins.programming.kicks-ass.net> References: <1459527854-5899-1-git-send-email-alexander.shishkin@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov , Paolo Bonzini , x86@kernel.org, kvm@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, Arnaldo Carvalho de Melo To: Alexander Shishkin Return-path: Received: from casper.infradead.org ([85.118.1.10]:57104 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933580AbcDFIwa (ORCPT ); Wed, 6 Apr 2016 04:52:30 -0400 Content-Disposition: inline In-Reply-To: <1459527854-5899-1-git-send-email-alexander.shishkin@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Apr 01, 2016 at 07:24:14PM +0300, Alexander Shishkin wrote: > +static void pt_config_stop(struct perf_event *event) > { > + u64 ctl = READ_ONCE(event->hw.config); > > + /* may be already stopped by a PMI*/ > + if (!(ctl & RTIT_CTL_TRACEEN)) > + return; > + > + ctl ^= RTIT_CTL_TRACEEN; Would that not be much less confusing when written like |= ? > wrmsrl(MSR_IA32_RTIT_CTL, ctl); > > + WRITE_ONCE(event->hw.config, ctl); > + > /* > * A wrmsr that disables trace generation serializes other PT > * registers and causes all data packets to be written to memory, > +void intel_pt_vmxon(int entry) > +{ > + struct pt *pt = this_cpu_ptr(&pt_ctx); > + struct perf_event *event; > + unsigned long flags; > + > + /* PT plays nice with VMX, do nothing */ > + if (pt_pmu.vmx) > + return; > + > + /* > + * VMX entry will clear RTIT_CTL.TraceEn; we need to make > + * sure to not try to set it while VMX is on. Disable > + * interrupts to avoid racing with pmu callbacks; > + * concurrent PMI should be handled fine. > + */ > + local_irq_save(flags); > + WRITE_ONCE(pt->vmx_on, entry); So you mix: "VMX is on" and "VMX entry", please pick one. Since the function is called vmxon, I find .entry a very confusing argument name. > + > + if (entry) { > + /* prevent pt_config_stop() from writing RTIT_CTL */ > + event = pt->handle.event; > + if (event) > + event->hw.config = 0; > + } > + local_irq_restore(flags); > +} > +EXPORT_SYMBOL_GPL(intel_pt_vmxon);