[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fdf97d96-fff9-4826-88eb-4b7f56b36c7b@intel.com>
Date: Fri, 17 Oct 2025 15:13:17 +0200
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Eric Dumazet <edumazet@...gle.com>
CC: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski
<kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, Simon Horman
<horms@...nel.org>, Kuniyuki Iwashima <kuniyu@...gle.com>,
<netdev@...r.kernel.org>, <eric.dumazet@...il.com>
Subject: Re: [PATCH v2 net-next] net: shrink napi_skb_cache_{put,get}() and
napi_skb_cache_get_bulk()
From: Eric Dumazet <edumazet@...gle.com>
Date: Thu, 16 Oct 2025 18:29:11 +0000
> Following loop in napi_skb_cache_put() is unrolled by the compiler
> even if CONFIG_KASAN is not enabled:
>
> for (i = NAPI_SKB_CACHE_HALF; i < NAPI_SKB_CACHE_SIZE; i++)
> kasan_mempool_unpoison_object(nc->skb_cache[i],
> kmem_cache_size(net_hotdata.skbuff_cache));
>
> We have 32 times this sequence, for a total of 384 bytes.
>
> 48 8b 3d 00 00 00 00 net_hotdata.skbuff_cache,%rdi
> e8 00 00 00 00 call kmem_cache_size
>
> This is because kmem_cache_size() is not an inline and not const,
> and kasan_unpoison_object_data() is an inline function.
>
> Cache kmem_cache_size() result in a variable, so that
> the compiler can remove dead code (and variable) when/if
> CONFIG_KASAN is unset.
>
> After this patch, napi_skb_cache_put() is inlined in its callers,
> and we avoid one kmem_cache_size() call in napi_skb_cache_get()
> and napi_skb_cache_get_bulk().
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Alexander Lobakin <aleksander.lobakin@...el.com>
Reviewed-by: Alexander Lobakin <aleksander.lobakin@...el.com>
Thanks,
Olek
Powered by blists - more mailing lists