[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zr8n6jliwJXqq7aZ@J2N7QTR9R3>
Date: Fri, 16 Aug 2024 11:20:26 +0100
From: Mark Rutland <mark.rutland@....com>
To: Robin Murphy <robin.murphy@....com>
Cc: will@...nel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, ilkka@...amperecomputing.com
Subject: Re: [PATCH 4/8] perf/arm-cmn: Improve build-time assertions
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 <robin.murphy@....com>
> ---
> 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
>
Powered by blists - more mailing lists