Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2226903imu; Fri, 23 Nov 2018 06:19:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/XYSbcQb29tuopglcoitpAFcAikFMEajhVI8VolLCzHUD9nKoi8TbcwmdZO/oafrR5iYcaa X-Received: by 2002:a63:104d:: with SMTP id 13mr14287401pgq.303.1542982785791; Fri, 23 Nov 2018 06:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542982785; cv=none; d=google.com; s=arc-20160816; b=hmAdcFjjERcmGGFpTKxpilVTUuIE9exQUfhggR+TtY2OuMoldn7jhQo7lGBjCqEKIf WIzfFZ0OZf2EU/VoZ8rTaV8kdxJwQeayFgPzoZPfpXKwY66C6RItM7VB4d7bpCQifJWB n0Dd4DX18jJW+3Jy/uPuZXnUoPyHH/Pvnt4qB23RmgLGsgpjoKBseD17GqqS0+N5+eNq hCTcefUoyrHvDX7gbSi03MZ/2OjiSscsCcjBpxhs4iChlfpZWk1635S+jRo5ARM6hQdl lfvFShdAa1nndYxx2ruILpNtQHtU3WIk1NxJmvM3zdIIL354E7xB3Hs/AVfeorgYIHzz DRuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6GoQshdtTCtgMebtwlHObzPjr944dMKihJzDk8JnA+E=; b=sFcQ5p24x5Eg4opEYbtjoqjpVQdP4YMvccXV6aIvlEErVCe30rFjJbn8hbrWNqHJ0J nyaNai5CmokK8mCWDHMqL4p1neNLS3YAUrWx1e0flUSydHbzZ0QkKgWpgnLNHEow8puW L36wGHu1CUFSse1VklIt7CfgCXRZT3K+/w0SGenHLVNp/rcpjW5s/dwz1z6CumgDQ8bj gVCC0jBx36rWzzD8rUCWrgCMvFS8MoS908NYm1HEDcoA7C6VixJG1fwIEDBwCpU2P0FN WvBHyEF/geGBaTmHM3ANGBaEWhYuJyAH1KO2q0RM9L1o3XA1n4SKAQjY9V5i7Wd4PLtI de4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=gN8XvJOL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19-v6si46923538pls.32.2018.11.23.06.19.30; Fri, 23 Nov 2018 06:19:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=gN8XvJOL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395053AbeKVXGZ (ORCPT + 99 others); Thu, 22 Nov 2018 18:06:25 -0500 Received: from merlin.infradead.org ([205.233.59.134]:39662 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394865AbeKVXGY (ORCPT ); Thu, 22 Nov 2018 18:06:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6GoQshdtTCtgMebtwlHObzPjr944dMKihJzDk8JnA+E=; b=gN8XvJOLSMf9Ga/u/ly10Llmm d94ZfD94B0B6/m6mCzv91TIyY3eHgeFCJL9dj5fuS93nGq7DX+i8Y/H/a3UzqrpyuLk6nLAbUoibz jFwPpe1WGtzIzPWssrpuIWEWzsayQsj2a9+m+cSKL3e8BQ6v8073C2AsmNS4QxtsSb8E44vmMhFcu au6wPlvaM6ksRF/BkswOOa1rYEsi/HVInl7A0PNOie2KYXkxJxLYQSrNnaKoKFBIZUkaZ3rktsycV iaKN4IdixwWgG7LgClwd5g0QSrNQ4FVwLAyV1IPpvfzP031JzYzlPfPl+O5p3oaes5Qa76i3cweT+ 2vWyx7Lvw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPo4E-0001H5-NY; Thu, 22 Nov 2018 12:26:49 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1753B2029FD58; Thu, 22 Nov 2018 13:26:37 +0100 (CET) Date: Thu, 22 Nov 2018 13:26:37 +0100 From: Peter Zijlstra To: Andrew Murray Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Shawn Guo , Sascha Hauer , Will Deacon , Mark Rutland , Benjamin Herrenschmidt , Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 00/10] perf/core: Generalise event exclusion checking Message-ID: <20181122122637.GS2131@hirez.programming.kicks-ass.net> References: <1542363853-13849-1-git-send-email-andrew.murray@arm.com> <20181119130800.GE9761@hirez.programming.kicks-ass.net> <20181122122142.GI42987@e119886-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122122142.GI42987@e119886-lin.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 12:21:43PM +0000, Andrew Murray wrote: > On Mon, Nov 19, 2018 at 02:08:00PM +0100, Peter Zijlstra wrote: > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > index 84530ab358c3..d76b724177b9 100644 > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -9772,6 +9772,14 @@ static int perf_try_init_event(struct pmu *pmu, struct perf_event *event) > > if (ctx) > > perf_event_ctx_unlock(event->group_leader, ctx); > > > > + if (!ret) { > > + if ((pmu->capabilities & PERF_PMU_CAP_EXCLUDE) || > > + event_has_exclude_flags(event)) { > > + event->destroy(event); > > + ret = -EINVAL; > > + } > > + } > > + > > I don't quite follow this logic. Should that not have been: > > if (!(pmu->capabilities & PERF_PMU_CAP_EXCLUDE) && > event_has_exclude_flags(event)) { > > Meaning that if an event has any exclude flags but the pmu doesn't > have the capability to handle them then error. Uhm, yes. Brainfart on my side that. > If you're happy with my proposed logic, then would it also make > sense to move this before the call to the pmu->event_init ? I'm not sure that can work; I think we need ->event_init() first such that it can -ENOENT. Only after ->event_init() returns success can we be certain of @pmu.