• Eric Dumazet's avatar
    net: add dedicated kmem_cache for typical/small skb->head · bf9f1baa
    Eric Dumazet authored
    Recent removal of ksize() in alloc_skb() increased
    performance because we no longer read
    the associated struct page.
    
    We have an equivalent cost at kfree_skb() time.
    
    kfree(skb->head) has to access a struct page,
    often cold in cpu caches to get the owning
    struct kmem_cache.
    
    Considering that many allocations are small (at least for TCP ones)
    we can have our own kmem_cache to avoid the cache line miss.
    
    This also saves memory because these small heads
    are no longer padded to 1024 bytes.
    
    CONFIG_SLUB=y
    $ grep skbuff_small_head /proc/slabinfo
    skbuff_small_head   2907   2907    640   51    8 : tunables    0    0    0 : slabdata     57     57      0
    
    CONFIG_SLAB=y
    $ grep skbuff_small_head /proc/slabinfo
    skbuff_small_head    607    624    640    6    1 : tunables   54   27    8 : slabdata    104    104      5
    
    Notes:
    
    - After Kees Cook patches and this one, we might
      be able to revert commit
      dbae2b06 ("net: skb: introduce and use a single page frag cache")
      because GRO_MAX_HEAD is also small.
    
    - This patch is a NOP for CONFIG_SLOB=y builds.
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
    Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
    Reviewed-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    bf9f1baa
skbuff.c 170 KB