Commit 181edb2b authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

net: Add skb_free_frag to replace use of put_page in freeing skb->head

This change adds a function called skb_free_frag which is meant to
compliment the function netdev_alloc_frag.  The general idea is to enable a
more lightweight version of page freeing since we don't actually need all
the overhead of a put_page, and we don't quite fit the model of __free_pages.
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b63ae8ca
...@@ -2182,6 +2182,11 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, ...@@ -2182,6 +2182,11 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev,
return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC); return __netdev_alloc_skb_ip_align(dev, length, GFP_ATOMIC);
} }
static inline void skb_free_frag(void *addr)
{
__free_page_frag(addr);
}
void *napi_alloc_frag(unsigned int fragsz); void *napi_alloc_frag(unsigned int fragsz);
struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, struct sk_buff *__napi_alloc_skb(struct napi_struct *napi,
unsigned int length, gfp_t gfp_mask); unsigned int length, gfp_t gfp_mask);
......
...@@ -436,7 +436,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, ...@@ -436,7 +436,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len,
skb = __build_skb(data, len); skb = __build_skb(data, len);
if (unlikely(!skb)) { if (unlikely(!skb)) {
put_page(virt_to_head_page(data)); skb_free_frag(data);
return NULL; return NULL;
} }
...@@ -490,7 +490,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, ...@@ -490,7 +490,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len,
skb = __build_skb(data, len); skb = __build_skb(data, len);
if (unlikely(!skb)) { if (unlikely(!skb)) {
put_page(virt_to_head_page(data)); skb_free_frag(data);
return NULL; return NULL;
} }
...@@ -549,10 +549,12 @@ static void skb_clone_fraglist(struct sk_buff *skb) ...@@ -549,10 +549,12 @@ static void skb_clone_fraglist(struct sk_buff *skb)
static void skb_free_head(struct sk_buff *skb) static void skb_free_head(struct sk_buff *skb)
{ {
unsigned char *head = skb->head;
if (skb->head_frag) if (skb->head_frag)
put_page(virt_to_head_page(skb->head)); skb_free_frag(head);
else else
kfree(skb->head); kfree(head);
} }
static void skb_release_data(struct sk_buff *skb) static void skb_release_data(struct sk_buff *skb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment