From patchwork Fri Mar 11 10:54:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 8564481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 43F54C0553 for ; Fri, 11 Mar 2016 10:56:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D4CC20222 for ; Fri, 11 Mar 2016 10:56:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AE5D20211 for ; Fri, 11 Mar 2016 10:56:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeKia-0005Ok-Ib; Fri, 11 Mar 2016 10:54:52 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeKiX-0005Lg-9V for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2016 10:54:49 +0000 Received: by mail-wm0-x242.google.com with SMTP id n186so1708338wmn.0 for ; Fri, 11 Mar 2016 02:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Qwt6j0D3AftVon3Ca2GgZrzTqfKpajX/Zg0ypprFVws=; b=H6/q8ogKySmj1aq1Keh2pOKsomTQt54nXqilZswh9DD+8ZB9PWfc68AzBhsKQeT+bX IpXZnQeb67gM5xD4Kyi0AuHifGZ0XReTyv6RM4WRV7oQNPYpyyorJquH0Wu2FyEMbWTV Ctk0pvxp1Q73TYbob3V5Fo0wl1ZDOcFUS3v3YkO6Req3Gv3DansPEeyca5utLdEu5XFb qKrha2Jqlg30dDBjQryh4jf3rpCEOAdRqEnnP7Pkcfw7Tdz7/faaU/SSVI0u3IU0MWbF PsFsCPdSRlbPrnu/XjlkY4TffCSkXR0beFOm73J3ISppXiObYLYJ4f6enJdQdbIKHHw3 SiZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Qwt6j0D3AftVon3Ca2GgZrzTqfKpajX/Zg0ypprFVws=; b=WzFA6+FqoxKRZzUywx10BszMFjk6zzMNw95DVBNSSS3XGCaP8zqvRG6jIWD273gohz Is6ELgh1M5ie+NkJVimvh0vnqSEEPXUrTHH5jVYk3kQ7UcvgHH7WXgHk6kqN7fqWMAPp kcBsoFuF9200oPDumgdscvoUvrb7/P2Q3HeIDPJmA+zwxHSCXINvrPjjaMbonj0t7FNn djdAw1lv66XqFFU1eAIm6VmZeuaRiJlgjpxwrGIa6BN2KMLY+/O3f2K5xLXe89knRUmZ uAFg7PywHo1YLFbj0ue9PNFVIfcY6Hzx+NvRHOvVWsk2UPts05IHCgCkFPJYxSLMsP08 nq9w== X-Gm-Message-State: AD7BkJKyH6ZV0j49wpJ5q5PjC4pROayhJkoYvv0toiU5OrMuW6JmKF9LQMR8ERh2FOUsRA== X-Received: by 10.194.9.34 with SMTP id w2mr8984187wja.170.1457693667542; Fri, 11 Mar 2016 02:54:27 -0800 (PST) Received: from wintermute (HSI-KBW-46-223-157-69.hsi.kabel-badenwuerttemberg.de. [46.223.157.69]) by smtp.gmail.com with ESMTPSA id gg7sm7903816wjd.10.2016.03.11.02.54.26 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Mar 2016 02:54:26 -0800 (PST) From: Jan Glauber X-Google-Original-From: Jan Glauber Date: Fri, 11 Mar 2016 11:54:24 +0100 To: Mark Rutland Subject: Re: [RFC PATCH 1/7] arm64/perf: Basic uncore counter support for Cavium ThunderX Message-ID: <20160311105423.GA4442@wintermute> References: <8bd93a25e069ed6428bc6c21fc53270962ccafcc.1455295032.git.jglauber@cavium.com> <20160212173658.GD20262@leverpostej> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160212173658.GD20262@leverpostej> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160311_025449_506635_FFC17016 X-CRM114-Status: GOOD ( 19.09 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Feb 12, 2016 at 05:36:59PM +0000, Mark Rutland wrote: > On Fri, Feb 12, 2016 at 05:55:06PM +0100, Jan Glauber wrote: [...] > > +int thunder_uncore_event_init(struct perf_event *event) > > +{ > > + struct hw_perf_event *hwc = &event->hw; > > + struct thunder_uncore *uncore; > > + > > + if (event->attr.type != event->pmu->type) > > + return -ENOENT; > > + > > + /* we do not support sampling */ > > + if (is_sampling_event(event)) > > + return -EINVAL; > > + > > + /* counters do not have these bits */ > > + if (event->attr.exclude_user || > > + event->attr.exclude_kernel || > > + event->attr.exclude_host || > > + event->attr.exclude_guest || > > + event->attr.exclude_hv || > > + event->attr.exclude_idle) > > + return -EINVAL; > > We should _really_ make these features opt-in at the core level. It's > crazy that each and every PMU drivers has to explicitly test and reject > things it doesn't support. > Looking at the exclude_* feature handling in pmu->event_init under arch/ shows lots of differences. Just as an example, exclude_idle returns sometimes -EINVAL, sometimes -EPERM while other archs ignore it and one silently deletes the flag. So it looks hard to me to move the exclude handling into perf core while keeping the per-arch differences. And if we don't and return an error on the perf_event_open syscall in a newer kernel for an exclude bit that was previously ignored it will be a user-space regression, right? Looking only at the uncore drivers (plus drivers/bus/arm-cc*) it looks like they all don't support any exclude bits but the handling here differs also. The table shows the current behaviour, X means the requested exclude flag is refused. user kernel host guest hv idle --------------------------------------------------------------------- x86 uncore intel | X X X X x86 uncore intel snb | X X X X X X x86 uncore intel cqm | X X X X X X x86 uncore intel cstate | X X X X X X x86 uncore intel rapl | X X X X X X x86 uncore amd | X X X X x86 uncore amd iommu | X X X X x86 uncore amd ibs | X X X X X X arm bus cci | X X X X X X arm bus ccn | X X X X ---------------------------------------------------------------------- How about simply adding a helper function to include/linux/perf_event.h that checks if _any_ of the exclude bits is set? We could then simplify the check-for-any exclude flag to: if (any_exclude_set(event)) return -EINVAL; What's your opinion? Jan diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index f5c5a3f..0eacdba0 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -849,6 +849,18 @@ static inline bool is_sampling_event(struct perf_event *event) return event->attr.sample_period != 0; } +static inline int any_exclude_set(struct perf_event *event) +{ + if (event->attr.exclude_user || + event->attr.exclude_kernel || + event->attr.exclude_host || + event->attr.exclude_guest || + event->attr.exclude_hv || + event->attr.exclude_idle) + return 1; + return 0; +} + /* * Return 1 for a software event, 0 for a hardware event */