From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754571AbdBNQ1V (ORCPT ); Tue, 14 Feb 2017 11:27:21 -0500 Received: from merlin.infradead.org ([205.233.59.134]:48242 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752271AbdBNQ1M (ORCPT ); Tue, 14 Feb 2017 11:27:12 -0500 Date: Tue, 14 Feb 2017 17:27:02 +0100 From: Peter Zijlstra To: Alexander Shishkin Cc: Ingo Molnar , linux-kernel@vger.kernel.org, vince@deater.net, eranian@google.com, Arnaldo Carvalho de Melo , Borislav Petkov , Thomas Gleixner Subject: Re: [PATCH 1/2] perf/x86/intel/pt: Fail event scheduling on conflict with VMX Message-ID: <20170214162702.GR6500@twins.programming.kicks-ass.net> References: <20170214132416.26400-1-alexander.shishkin@linux.intel.com> <20170214132416.26400-2-alexander.shishkin@linux.intel.com> <20170214135620.GN6500@twins.programming.kicks-ass.net> <87d1eklpb9.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d1eklpb9.fsf@ashishki-desk.ger.corp.intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 14, 2017 at 06:17:30PM +0200, Alexander Shishkin wrote: > Peter Zijlstra writes: > > > On Tue, Feb 14, 2017 at 03:24:15PM +0200, Alexander Shishkin wrote: > >> At the moment, if VMX operation prevents PT tracing, the PMU will > >> silently return success to the event scheduling code, which will > >> track its 'on' time, etc. Instead, report failure so that perf > >> core knows this event is not actually on. > >> > >> Signed-off-by: Alexander Shishkin > >> Reported-by: Andi Kleen > >> Fixes: 1c5ac21a0e ("perf/x86/intel/pt: Don't die on VMXON") > >> --- > >> arch/x86/events/intel/pt.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c > >> index d92a60ef08..9372fa4549 100644 > >> --- a/arch/x86/events/intel/pt.c > >> +++ b/arch/x86/events/intel/pt.c > >> @@ -1335,7 +1335,7 @@ static void pt_event_start(struct perf_event *event, int mode) > >> struct pt_buffer *buf; > >> > >> if (READ_ONCE(pt->vmx_on)) > >> - return; > >> + goto fail_stop; > >> > >> buf = perf_aux_output_begin(&pt->handle, event); > >> if (!buf) > > > > I'm not getting it; how does this matter to the time tracking in > > event_sched_in() / event_sched_out() ? > > > > That looks at event->state == PERF_EVENT_STATE* > > > > This goto affects event->hw.state == PERF_HES_ > > > > The core assumes ->start() will _NOT_ fail. > > This is called by pmu::add(), which checks hw.state afterwards and if it > finds HES_STOPPED, it returns an error, which event_sched_in() captures > and keeps the event in INACTIVE state. Should I add a comment about it? Egads... so what if ->add() succeeds but we then hit this on ->stop()/->start() due to throttle or period adjust? Now I suppose PT will never normally hit either of those, but you can do IOC_PERIOD on it, just for giggles. Yes, this very much needs a comment... Also, should not this then live in ->add() in the first place?