Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 07 Feb 2019 16:36:32 -0000 Received: from mga09.intel.com ([134.134.136.24]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1grmeL-0006ye-GD for speck@linutronix.de; Thu, 07 Feb 2019 17:35:42 +0100 Date: Thu, 7 Feb 2019 08:35:39 -0800 From: Andi Kleen Subject: [MODERATED] Re: [PATCH v2 0/8] PERFv2 Message-ID: <20190207163539.GS31598@tassilo.jf.intel.com> References: <20190207132709.GA32477@hirez.programming.kicks-ass.net> <20190207143759.GP31598@tassilo.jf.intel.com> <20190207153330.GD32477@hirez.programming.kicks-ass.net> MIME-Version: 1.0 In-Reply-To: <20190207153330.GD32477@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Thu, Feb 07, 2019 at 04:33:30PM +0100, speck for Peter Zijlstra wrote: > On Thu, Feb 07, 2019 at 06:37:59AM -0800, speck for Andi Kleen wrote: > > > A few questions: > > > > > > - How will this 'feature' interact with MSR_CORE_PERF_GLOBAL_CTRL ? > > > > It's completely independent of GLOBAL_CTRL on the software level. > > Internally it uses it, but it shouldn't be software visible. > > So if you write GLOBAL_CTRL=0 and then use RTM instructions, the ucode > doesn't set GLOBAL_CTRL.3 = 1 ? It would have to, otherwise I don't see > how it would work. It sets it internally, but only temporarily. You can't actually observe it because you can't do a RDMSR inside a transaction. > > > > - Is having GLOBAL_CTRL.3 0 and not using RTM instructions enough > > > guarantee to avoid PMC3 from being clobbered? > > > > With no use of RTM clobbering should be fairly unlikely, > > but in theory it could happen if RETPOLINE is not used > > (due to an indirect branch mistakenenly executing something > > that looks like XBEGIN). If we assume that RETPOLINE > > is used I believe it shouldn't happen in the kernel at least. > > Even without RETPOLINE such a case should be fairly unlikely, > > but cannot be 100% ruled out. > > > > > Esp. that latter question, because both your patches and the below seems > > > to rely on that; and if the answer is yet, the below can be further > > > simplified. > > > > I don't see how I rely on that? > > Your, like my earlier patch, hooks into x86_pmu.enable_event, but if you > look at x86_pmu_start(), we only call that _after_ > x86_perf_event_set_period() which would program CNTVAL3. True. > > If we cannot rely on the PMC3 state being stable, we have to add a hook. I guess it's ok. RETPOLINE is a reasonable requirement. I'll make sure to spell it out. In theory we could add a warning if it's not used, but that might be overkill. -Andi