summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAlexander Lobakin <alobakin@pm.me>2021-02-13 14:12:38 +0000
committerDavid S. Miller <davem@davemloft.net>2021-02-13 14:32:04 -0800
commitd13612b58e6453fc664f282514fe2bd7b848230f (patch)
tree40e77ecc6855d9d592229d4a572b818d4e5e0491 /net
parentf450d539c05a14c103dd174718f81bb2fe65cb4b (diff)
skbuff: allow to optionally use NAPI cache from __alloc_skb()
Reuse the old and forgotten SKB_ALLOC_NAPI to add an option to get an skbuff_head from the NAPI cache instead of inplace allocation inside __alloc_skb(). This implies that the function is called from softirq or BH-off context, not for allocating a clone or from a distant node. Cc: Alexander Duyck <alexander.duyck@gmail.com> # Simplified flags check Signed-off-by: Alexander Lobakin <alobakin@pm.me> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 9e1a8ded4acc..a80581eed7fc 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -405,7 +405,11 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
gfp_mask |= __GFP_MEMALLOC;
/* Get the HEAD */
- skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
+ if ((flags & (SKB_ALLOC_FCLONE | SKB_ALLOC_NAPI)) == SKB_ALLOC_NAPI &&
+ likely(node == NUMA_NO_NODE || node == numa_mem_id()))
+ skb = napi_skb_cache_get();
+ else
+ skb = kmem_cache_alloc_node(cache, gfp_mask & ~GFP_DMA, node);
if (unlikely(!skb))
return NULL;
prefetchw(skb);