mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
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>
This commit is contained in:
parent
483126b3b2
commit
df1ae022af
@ -339,8 +339,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
|
|||||||
|
|
||||||
/* Get the HEAD */
|
/* Get the HEAD */
|
||||||
skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
|
skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
|
||||||
if (!skb)
|
if (unlikely(!skb))
|
||||||
goto out;
|
return NULL;
|
||||||
prefetchw(skb);
|
prefetchw(skb);
|
||||||
|
|
||||||
/* We do our best to align skb_shared_info on a separate cache
|
/* 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(size);
|
||||||
size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
|
size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
|
||||||
data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
|
data = kmalloc_reserve(size, gfp_mask, node, &pfmemalloc);
|
||||||
if (!data)
|
if (unlikely(!data))
|
||||||
goto nodata;
|
goto nodata;
|
||||||
/* kmalloc(size) might give us more room than requested.
|
/* kmalloc(size) might give us more room than requested.
|
||||||
* Put skb_shared_info exactly at the end of allocated zone,
|
* 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());
|
skb_set_kcov_handle(skb, kcov_common_handle());
|
||||||
|
|
||||||
out:
|
|
||||||
return skb;
|
return skb;
|
||||||
|
|
||||||
nodata:
|
nodata:
|
||||||
kmem_cache_free(cache, skb);
|
kmem_cache_free(cache, skb);
|
||||||
skb = NULL;
|
return NULL;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__alloc_skb);
|
EXPORT_SYMBOL(__alloc_skb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user