Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2377142imu; Fri, 23 Nov 2018 08:18:48 -0800 (PST) X-Google-Smtp-Source: AJdET5eRXCTf3AdbG74X+HTEyTFDvm2J4epDswfKPax/hGUhOh/ZUkmcFkPFjlX/IDMlvx72WM3R X-Received: by 2002:a62:e044:: with SMTP id f65mr16448959pfh.208.1542989928793; Fri, 23 Nov 2018 08:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542989928; cv=none; d=google.com; s=arc-20160816; b=r3jNTbwq0h5V8pIzvfcpH9vVLfFatSDNL2Uz1y992y0Fl/B9LF5TmsV9Mcs9t2lM7M CGBww9yMsu6W+2peUH7fUm0ccl8oxo3V89eD6/NT3Loya2chRZUxnyxUbAP2J+KUVbjl gqlwwd8r+r/NTQesU5sSmdf9G3h6zVvhoEgDz1BWICzqgg8mydu6y0C0Uayd7bQAH5F9 pe22Izf6/YPi1XaTF4v6/dXHHgYL9GhxAIjLU8CxduYg7HnOq6kIe67deXrd2jo72ryE m4BGtJ8j1OQwKbfUyQaQTkw0B/dqhI6jvvBtOYJASMHibpmtvs/FMHrTg8tUL+OIFHGV m52Q== 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; bh=iGrd3n0bD10chdXHrwlMZ5MbxWno2oehxsz6GlzW8ms=; b=JVnXymf0H7Ww87yxZKSQcNezWVUdJ9n2+ERf/JwIWGZlz07fgf1lyodU1027uhmyYN 9KWzTvEVLa5Yf5CNmxtJY/pOskqUJ/NmB0l7hIihEt8b6gB++onTdHzMRFVMeGDGdhe4 SLoJAwkc5N00bHZ2X28unaT6mhbYDC0aVW94bhS+PZXTbuk+22JRKklPzxLff2EPOrSW Dc87nHuibfArB+cSHVllgZ0uc0TMGSNVBr+2AoOryilOYa9N9LjT78SDOPMrQEO8hIOm dltzgYYzN/sIURU7USRA1HWZRKrNy8bB8XmgwPMyNNhaHrq4RNcMck/N5Pp1+aLnK3Ns XdaQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b124si34797153pfg.47.2018.11.23.08.18.20; Fri, 23 Nov 2018 08:18:48 -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; 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 S2391142AbeKVXiR (ORCPT + 99 others); Thu, 22 Nov 2018 18:38:17 -0500 Received: from foss.arm.com ([217.140.101.70]:47862 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732044AbeKVXiR (ORCPT ); Thu, 22 Nov 2018 18:38:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C31753622; Thu, 22 Nov 2018 04:59:02 -0800 (PST) Received: from localhost (unknown [10.37.6.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 58EE93F5A0; Thu, 22 Nov 2018 04:59:02 -0800 (PST) Date: Thu, 22 Nov 2018 12:59:00 +0000 From: Andrew Murray To: Peter Zijlstra 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: <20181122125859.GJ42987@e119886-lin.cambridge.arm.com> 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> <20181122122637.GS2131@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181122122637.GS2131@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) 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 01:26:37PM +0100, Peter Zijlstra wrote: > 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. Ah yes I see now. Until event_init doesn't return -ENOENT we can't be sure that this will be the PMU we use (as per the other calls to perf_try_init_event in perf_init_event). Thanks, Andrew Murray