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:49:39 -0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1grmrq-0007SB-2k for speck@linutronix.de; Thu, 07 Feb 2019 17:49:38 +0100 Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1grmrn-00048j-UV for speck@linutronix.de; Thu, 07 Feb 2019 16:49:36 +0000 Date: Thu, 7 Feb 2019 17:49:32 +0100 From: Peter Zijlstra Subject: [MODERATED] Re: [PATCH v2 0/8] PERFv2 Message-ID: <20190207164932.GC32511@hirez.programming.kicks-ass.net> References: <20190207132709.GA32477@hirez.programming.kicks-ass.net> <20190207143759.GP31598@tassilo.jf.intel.com> <20190207153728.GE32477@hirez.programming.kicks-ass.net> <20190207162047.GR31598@tassilo.jf.intel.com> MIME-Version: 1.0 In-Reply-To: <20190207162047.GR31598@tassilo.jf.intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Thu, Feb 07, 2019 at 08:20:47AM -0800, speck for Andi Kleen wrote: > > > Doesn't that overwrite the global shared constraints constraints? > > > Would need to make them non const at least, it will likely fault. > > > > They are !const; we already update them at init time (for example we add > > the GPRs to the fixed ones etc..). > > Surely not for emptyconstraint ? We leave that empty indeed :-), but it isn't const either (although it could've been). Luckily emptyconstraint doesn't actually have PMC3 set, so we don't have to clear it (of course the code as proposed by me does the superfluous store). Anyway; I suspect we could use the dynamic constraints here and avoid some of the obvious fail. I just need to re-read how all that was supposed to work. But it looks like cpuc->constraints_list[] already has all we need. So I _think_ something like so... static struct event_constraint * skl_get_event_constraints(struct cpu_hw_events *cpuc, int idx, struct perf_event *event) { struct event_constraint *c; u64 mask; c = hsw_get_event_constraints(cpuc, idx, event); if (!force_rtm_abort) { /* * Without TFA we must not use PMC3. */ mask = c->idxmsk64 & ~(1ULL << 3); if (mask != c->idxmsk64) { if (!(c->flags & PERF_X86_EVENT_DYNAMIC)) { struct event_constraint *cx; cx = &cpuc->constraint_list[idx]; *cx = *c; cx->flag |= PERF_X86_EVENT_DYNAMIC; c = cx; } c->idxmsk64 = mask; c->weight = hweight64(mask); } } return c; } > > > Okay I see you rely on it being guarded by the global, but for virtualization > > > support will need the copy. > > > > > > Would need a copy at least. > > > > I've not thought abou virt yet; do we _have_ to expose the thing to > > guests? > > Yes I think so. It's the only way to use all four counters in a guest. The host could set force_rtm_abort if that is important.