[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKVc9J5511u2GO7Qpc=CShhhRf+qN5NmEv5bnHcUM6d1g@mail.gmail.com>
Date: Thu, 26 Oct 2023 11:42:45 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Coco Li <lixiaoyan@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>, Neal Cardwell <ncardwell@...gle.com>,
Mubashir Adnan Qureshi <mubashirq@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>,
Jonathan Corbet <corbet@....net>, David Ahern <dsahern@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, netdev@...r.kernel.org, Chao Wu <wwchao@...gle.com>,
Wei Wang <weiwan@...gle.com>, Pradeep Nemavat <pnemavat@...gle.com>
Subject: Re: [PATCH v4 net-next 2/6] cache: enforce cache groups
On Thu, Oct 26, 2023 at 10:20 AM Coco Li <lixiaoyan@...gle.com> wrote:
>
> Set up build time warnings to safegaurd against future header changes of
safeguard
> organized structs.
>
> Signed-off-by: Coco Li <lixiaoyan@...gle.com>
> Suggested-by: Daniel Borkmann <daniel@...earbox.net>
> Acked-by: Daniel Borkmann <daniel@...earbox.net>
Reviewed-by: Eric Dumazet <edumazet@...gle.com>
> ---
> include/linux/cache.h | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/include/linux/cache.h b/include/linux/cache.h
> index 9900d20b76c28..4e547beccd6a5 100644
> --- a/include/linux/cache.h
> +++ b/include/linux/cache.h
> @@ -85,6 +85,24 @@
> #define cache_line_size() L1_CACHE_BYTES
> #endif
>
> +#ifndef __cacheline_group_begin
> +#define __cacheline_group_begin(GROUP) \
> + __u8 __cacheline_group_begin__##GROUP[0]
> +#endif
> +
> +#ifndef __cacheline_group_end
> +#define __cacheline_group_end(GROUP) \
> + __u8 __cacheline_group_end__##GROUP[0]
> +#endif
> +
> +#ifndef CACHELINE_ASSERT_GROUP_MEMBER
> +#define CACHELINE_ASSERT_GROUP_MEMBER(TYPE, GROUP, MEMBER) \
> + BUILD_BUG_ON(!(offsetof(TYPE, MEMBER) >= \
> + offsetofend(TYPE, __cacheline_group_begin__##GROUP) && \
> + offsetofend(TYPE, MEMBER) <= \
> + offsetof(TYPE, __cacheline_group_end__##GROUP)))
> +#endif
> +
> /*
> * Helper to add padding within a struct to ensure data fall into separate
> * cachelines.
> --
> 2.42.0.758.gaed0368e0e-goog
>
Powered by blists - more mailing lists