mbox series

[net-next,0/4] net: core: use a dedicated kmem_cache for skb head allocs

Message ID 20230202185801.4179599-1-edumazet@google.com (mailing list archive)
Headers show
Series net: core: use a dedicated kmem_cache for skb head allocs | expand

Message

Eric Dumazet Feb. 2, 2023, 6:57 p.m. UTC
Our profile data show that using kmalloc(non_const_size)/kfree(ptr)
has a certain cost, because kfree(ptr) has to pull a 'struct page'
in cpu caches.

Using a dedicated kmem_cache for TCP skb->head allocations makes
a difference, both in cpu cycles and memory savings.

This kmem_cache could also be used for GRO skb allocations,
this is left as a future exercise.

Eric Dumazet (4):
  net: add SKB_HEAD_ALIGN() helper
  net: remove osize variable in __alloc_skb()
  net: factorize code in kmalloc_reserve()
  net: add dedicated kmem_cache for typical/small skb->head

 include/linux/skbuff.h |  8 ++++
 net/core/skbuff.c      | 95 +++++++++++++++++++++++++++---------------
 2 files changed, 70 insertions(+), 33 deletions(-)

Comments

Paolo Abeni Feb. 6, 2023, 6:16 p.m. UTC | #1
On Thu, 2023-02-02 at 18:57 +0000, Eric Dumazet wrote:
> Our profile data show that using kmalloc(non_const_size)/kfree(ptr)
> has a certain cost, because kfree(ptr) has to pull a 'struct page'
> in cpu caches.
> 
> Using a dedicated kmem_cache for TCP skb->head allocations makes
> a difference, both in cpu cycles and memory savings.
> 
> This kmem_cache could also be used for GRO skb allocations,
> this is left as a future exercise.
> 
> Eric Dumazet (4):
>   net: add SKB_HEAD_ALIGN() helper
>   net: remove osize variable in __alloc_skb()
>   net: factorize code in kmalloc_reserve()
>   net: add dedicated kmem_cache for typical/small skb->head
> 
>  include/linux/skbuff.h |  8 ++++
>  net/core/skbuff.c      | 95 +++++++++++++++++++++++++++---------------
>  2 files changed, 70 insertions(+), 33 deletions(-)

LGTM,

Acked-by: Paolo Abeni <pabeni@redhat.com>

Thanks!

Paolo