From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEBC5CA9EC3 for ; Thu, 31 Oct 2019 07:55:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 774DE2086D for ; Thu, 31 Oct 2019 07:55:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j9z8RsID" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 774DE2086D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/3AtEc8g6SUne3RdmjBaGNLnlGnxl7S4MTp1oh1uYW0=; b=j9z8RsIDHRinHS 5Bz63KBu4G7B1PsHNkWGI4KY0HTVQAKpTNyphj1ILjnoTVEGJBsLfBOb70UBrpVnOC6SG8jp9oi6d kpOjiePt/FV8bbKgroB9/LoyXjlXQmX4K9fgYdybOFb2zVUC+5LsRsgYJ56DtiaqbEWLd+pdLm5ER SgGGd1zUQkZc4YvHyPnhPQ7d685CZydypJj4H3ThUnbv/rK4BAr8GXaBr2f9l16k+MPRQhJYwTA0L 45kOucduKmgkkStIBLWnLHxVsv2Y917bY5GZNMKNNDTlDZy7FpkOTYd4+nVOWy2pDz7svygKD1ovb PJJCwt169hoHSZZRLWyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQ5Ii-000280-Ow; Thu, 31 Oct 2019 07:55:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQ5Ie-00027K-6u for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2019 07:55:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1BF3A1FB; Thu, 31 Oct 2019 00:55:14 -0700 (PDT) Received: from blommer (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CDE643F71E; Thu, 31 Oct 2019 00:55:12 -0700 (PDT) Date: Thu, 31 Oct 2019 07:55:06 +0000 From: Mark Rutland To: Richard Henderson Subject: Re: [PATCH] arm64: perf: Simplify the ARMv8 PMUv3 event attributes Message-ID: <20191031075505.GA3412@blommer> References: <1572407177-48229-1-git-send-email-zhangshaokun@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191031_005520_302690_0221D108 X-CRM114-Status: GOOD ( 17.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shaokun Zhang , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 30, 2019 at 02:34:37PM +0100, Richard Henderson wrote: > On 10/30/19 4:46 AM, Shaokun Zhang wrote: > > For each PMU event, there is a ARMV8_EVENT_ATTR(xx, XX) and > > &armv8_event_attr_xx.attr.attr. Let's redefine the ARMV8_EVENT_ATTR > > to simplify the armv8_pmuv3_event_attrs. > ... > > #define ARMV8_EVENT_ATTR(name, config) \ > > + (&((struct perf_pmu_events_attr[]) { \ > > + { .attr = __ATTR(name, 0444, armv8pmu_events_sysfs_show, NULL), \ > > + .id = config, } \ > > + })[0].attr.attr) > > > > static struct attribute *armv8_pmuv3_event_attrs[] = { > > + ARMV8_EVENT_ATTR(sw_incr, ARMV8_PMUV3_PERFCTR_SW_INCR), > > You do realize this creates complete perf_pmu_events_attr structures, most of > which is unused and unreachable, right? In armv8pmu_events_sysfs_show() we use container_of() to access the perf_pmu_events_attr, and extracts the id field: | static ssize_t | armv8pmu_events_sysfs_show(struct device *dev, | struct device_attribute *attr, char *page) | { | struct perf_pmu_events_attr *pmu_attr; | | pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr); | | return sprintf(page, "event=0x%03llx\n", pmu_attr->id); | } > Also, why not take the opportunity to assert that the armv8_pmuv3_event_attrs > array cannot get out of sync with the ARMV8_PMUV3_* defines? > > Slightly better would seem to be > > #define ARMV8_EVENT_ATTR(name, config) \ > [config] = &((struct device_attribute) \ > __ATTR(name, 0444, armv8pmu_events_sysfs_show, NULL)).attr I'm not sure I follow. This is not equivalent, and you're using the config field in a very different way -- that's not an index in the parent array in the current code. How do you expect armv8pmu_events_sysfs_show to get the config value in this case? > > though I'm not sure why __ATTR is particularly desired above > > #define ARMV8_EVENT_ATTR(name, config) \ > [config] = &(struct attribute){ \ > .name = __stringify(name), \ > .mode = 0444, \ > } Using __ATTR is consistent with other drivers, so I don't see a reason to change that unless there's a significant simplification, or a functional improvement Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel