diff options
author | Alexander Duyck <alexander.h.duyck@redhat.com> | 2014-12-09 22:40:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-10 13:31:57 -0500 |
commit | fd11a83dd3630ec6a60f8a702446532c5c7e1991 (patch) | |
tree | 4ab4c6966cfbd5ff9bb437592cf6e59c4ef6859d /include/linux/skbuff.h | |
parent | ffde7328a36d16e626bae8468571858d71cd010b (diff) |
net: Pull out core bits of __netdev_alloc_skb and add __napi_alloc_skb
This change pulls the core functionality out of __netdev_alloc_skb and
places them in a new function named __alloc_rx_skb. The reason for doing
this is to make these bits accessible to a new function __napi_alloc_skb.
In addition __alloc_rx_skb now has a new flags value that is used to
determine which page frag pool to allocate from. If the SKB_ALLOC_NAPI
flag is set then the NAPI pool is used. The advantage of this is that we
do not have to use local_irq_save/restore when accessing the NAPI pool from
NAPI context.
In my test setup I saw at least 11ns of savings using the napi_alloc_skb
function versus the netdev_alloc_skb function, most of this being due to
the fact that we didn't have to call local_irq_save/restore.
The main use case for napi_alloc_skb would be for things such as copybreak
or page fragment based receive paths where an skb is allocated after the
data has been received instead of before.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 736cc99f3f6c..85ab7d72b54c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -151,6 +151,7 @@ struct net_device; | |||
151 | struct scatterlist; | 151 | struct scatterlist; |
152 | struct pipe_inode_info; | 152 | struct pipe_inode_info; |
153 | struct iov_iter; | 153 | struct iov_iter; |
154 | struct napi_struct; | ||
154 | 155 | ||
155 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 156 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
156 | struct nf_conntrack { | 157 | struct nf_conntrack { |
@@ -673,6 +674,7 @@ struct sk_buff { | |||
673 | 674 | ||
674 | #define SKB_ALLOC_FCLONE 0x01 | 675 | #define SKB_ALLOC_FCLONE 0x01 |
675 | #define SKB_ALLOC_RX 0x02 | 676 | #define SKB_ALLOC_RX 0x02 |
677 | #define SKB_ALLOC_NAPI 0x04 | ||
676 | 678 | ||
677 | /* Returns true if the skb was allocated from PFMEMALLOC reserves */ | 679 | /* Returns true if the skb was allocated from PFMEMALLOC reserves */ |
678 | static inline bool skb_pfmemalloc(const struct sk_buff *skb) | 680 | static inline bool skb_pfmemalloc(const struct sk_buff *skb) |
@@ -2165,6 +2167,13 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, | |||
2165 | } | 2167 | } |
2166 | 2168 | ||
2167 | void *napi_alloc_frag(unsigned int fragsz); | 2169 | void *napi_alloc_frag(unsigned int fragsz); |
2170 | struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, | ||
2171 | unsigned int length, gfp_t gfp_mask); | ||
2172 | static inline struct sk_buff *napi_alloc_skb(struct napi_struct *napi, | ||
2173 | unsigned int length) | ||
2174 | { | ||
2175 | return __napi_alloc_skb(napi, length, GFP_ATOMIC); | ||
2176 | } | ||
2168 | 2177 | ||
2169 | /** | 2178 | /** |
2170 | * __dev_alloc_pages - allocate page for network Rx | 2179 | * __dev_alloc_pages - allocate page for network Rx |