[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9050bdec-b34a-4133-8ba5-021dfd4b1c75@intel.com>
Date: Fri, 1 Mar 2024 13:58:39 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Kees
Cook <keescook@...omium.org>
CC: "David S. Miller" <davem@...emloft.net>, Paolo Abeni <pabeni@...hat.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, "Gustavo A. R. Silva"
<gustavoars@...nel.org>, <netdev@...r.kernel.org>,
<linux-hardening@...r.kernel.org>, Simon Horman <horms@...nel.org>, "Jiri
Pirko" <jiri@...nulli.us>, Daniel Borkmann <daniel@...earbox.net>, Coco Li
<lixiaoyan@...gle.com>, Amritha Nambiar <amritha.nambiar@...el.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] netdev: Use flexible array for trailing private bytes
From: Eric Dumazet <edumazet@...gle.com>
Date: Fri, 1 Mar 2024 09:03:55 +0100
> On Fri, Mar 1, 2024 at 7:59 AM Jakub Kicinski <kuba@...nel.org> wrote:
>>
>> On Thu, 29 Feb 2024 13:30:22 -0800 Kees Cook wrote:
Re WARN_ONCE() in netdev_priv(): netdev_priv() is VERY hot, I'm not sure
we want to add checks there. Maybe under CONFIG_DEBUG_NET?
>
>>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>>> index 118c40258d07..b476809d0bae 100644
>>> --- a/include/linux/netdevice.h
>>> +++ b/include/linux/netdevice.h
>>> @@ -1815,6 +1815,8 @@ enum netdev_stat_type {
>>> NETDEV_PCPU_STAT_DSTATS, /* struct pcpu_dstats */
>>> };
>>>
>>> +#define NETDEV_ALIGN 32
>>
>> Unless someone knows what this is for it should go.
>> Align priv to cacheline size.
>
> +2
>
Maybe
> #define NETDEV_ALIGN L1_CACHE_BYTES
#define NETDEV_ALIGN max(SMP_CACHE_BYTES, 32)
?
(or even max(1 << INTERNODE_CACHE_SHIFT, 32))
>
> or a general replacement of NETDEV_ALIGN....
>
>
+ I'd align both struct net_device AND its private space to
%NETDEV_ALIGN and remove this weird PTR_ALIGN. {k,v}malloc ensures
natural alignment of allocations for at least a couple years already
(IOW if struct net_device is aligned to 64, {k,v}malloc will *always*
return a 64-byte aligned address).
Thanks,
Olek
Powered by blists - more mailing lists