summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAlexander Lobakin <alobakin@pm.me>2021-02-13 17:11:39 +0300
committerDavid S. Miller <davem@davemloft.net>2021-02-14 01:32:03 +0300
commitdf1ae022af2cd79f7ad3c65d95369d4649feea52 (patch)
tree5fcb514bc70522cb3e86a6fb9f93dd79639ab4b5 /net
parent483126b3b2c649c0ef95f67ac75d3c99390d6cc8 (diff)
downloadlinux-df1ae022af2cd79f7ad3c65d95369d4649feea52.tar.xz
skbuff: simplify __alloc_skb() a bit
Use unlikely() annotations for skbuff_head and data similarly to the two other allocation functions and remove totally redundant goto. 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.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c7d184e11547..88566de26cd1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -339,8 +339,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
/* Get the HEAD */
skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
- if (!skb)
- goto out;
+ if (unlikely(!skb))
+ return NULL;
prefetchw(skb);
/* We do our best to align skb_shared_info on a separate cache
@@ -351,7 +351,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
size = SKB_DATA_ALIGN(size);
size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
- if (!data)
+ if (unlikely(!data))
goto nodata;
/* kmalloc(size) might give us more room than requested.
* Put skb_shared_info exactly at the end of allocated zone,
@@ -395,12 +395,11 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
skb_set_kcov_handle(skb, kcov_common_handle());
-out:
return skb;
+
nodata:
kmem_cache_free(cache, skb);
- skb = NULL;
- goto out;
+ return NULL;
}
EXPORT_SYMBOL(__alloc_skb);