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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B4DCDC531DC for ; Fri, 16 Aug 2024 10:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xmquOZXrGHqq5FuDGTIjBbJxMQQrt58+Uf5+i/rjirk=; b=XdudAJoFWFFGWdLzNhcAhfdsQo XZfD7+l7YrsTXFxlY0cdTUpDS+orlMOeYadHB1LaVrQkrgPnvdQ1BuLh70wJK7cOE9DEO8R/CQKnp njaDlh6BEw1aGgiXbtJjPNyE46G/rwrT/Mwi9mqkmDjGZR094OI55rkE1YtkvvrLBldcbNRyeuv6T w6EXYwPRqfD/NaptP5IbCDaKApaVHoi/ZsZFGiNn4n8fMydDN7cssHp8lHCPm20c+4P4fjuIojB1m hlEweEYUpr7WgvnznQWcN/vWGbD/wYHd4uSllbxOKgMRhwW1vnYrQYe7eLEcjOjFot549CK7WuXEQ 8e/RkubA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seu5M-0000000CZnv-0YDP; Fri, 16 Aug 2024 10:21:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seu4M-0000000CZaA-0AWC for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 10:20:31 +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 68DBC143D; Fri, 16 Aug 2024 03:20:55 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 866CA3F73B; Fri, 16 Aug 2024 03:20:28 -0700 (PDT) Date: Fri, 16 Aug 2024 11:20:26 +0100 From: Mark Rutland To: Robin Murphy Cc: will@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ilkka@os.amperecomputing.com Subject: Re: [PATCH 4/8] perf/arm-cmn: Improve build-time assertions Message-ID: References: <2aabebd619b65416a6cd2ca7058ca85fa3656958.1723229941.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2aabebd619b65416a6cd2ca7058ca85fa3656958.1723229941.git.robin.murphy@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_032030_140040_1C950787 X-CRM114-Status: GOOD ( 18.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 09, 2024 at 08:15:43PM +0100, Robin Murphy wrote: > These days we can use static_assert() in the logical place rather than > jamming a BUILD_BUG_ON() into the nearest function scope. And since it > is now so convenient to do so, let's add an extra one to reinforce the > dtm_idx bitmap as well. > > Signed-off-by: Robin Murphy > --- > drivers/perf/arm-cmn.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c > index c9a2b21a7aec..8f7a1a6f8ab7 100644 > --- a/drivers/perf/arm-cmn.c > +++ b/drivers/perf/arm-cmn.c > @@ -577,6 +577,9 @@ struct arm_cmn_hw_event { > bool wide_sel; > enum cmn_filter_select filter_sel; > }; > +static_assert(sizeof(struct arm_cmn_hw_event) <= offsetof(struct hw_perf_event, target)); Moving this out seems fine. > +/* Currently XPs are the node type we can have most of; others top out at 128 */ > +static_assert(sizeof_field(struct arm_cmn_hw_event, dtm_idx) >= CMN_MAX_XPS / 4); I reckon we can make this true by construction (as on the last patch), and avoid the need for the assert entirely. Mark. > > #define for_each_hw_dn(hw, dn, i) \ > for (i = 0, dn = hw->dn; i < hw->num_dns; i++, dn++) > @@ -587,7 +590,6 @@ struct arm_cmn_hw_event { > > static struct arm_cmn_hw_event *to_cmn_hw(struct perf_event *event) > { > - BUILD_BUG_ON(sizeof(struct arm_cmn_hw_event) > offsetof(struct hw_perf_event, target)); > return (struct arm_cmn_hw_event *)&event->hw; > } > > -- > 2.39.2.101.g768bb238c484.dirty >