提交 231d06ae 编写于 作者: J Jörn Engel 提交者: David S. Miller

[NET]: Uninline kfree_skb and allow NULL argument

o Uninline kfree_skb, which saves some 15k of object code on my notebook.

o Allow kfree_skb to be called with a NULL argument.

  Subsequent patches can remove conditional from drivers and further
  reduce source and object size.
Signed-off-by: NJrn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2e1f47c7
...@@ -304,6 +304,7 @@ struct sk_buff { ...@@ -304,6 +304,7 @@ struct sk_buff {
#include <asm/system.h> #include <asm/system.h>
extern void kfree_skb(struct sk_buff *skb);
extern void __kfree_skb(struct sk_buff *skb); extern void __kfree_skb(struct sk_buff *skb);
extern struct sk_buff *__alloc_skb(unsigned int size, extern struct sk_buff *__alloc_skb(unsigned int size,
gfp_t priority, int fclone); gfp_t priority, int fclone);
...@@ -403,22 +404,6 @@ static inline struct sk_buff *skb_get(struct sk_buff *skb) ...@@ -403,22 +404,6 @@ static inline struct sk_buff *skb_get(struct sk_buff *skb)
* atomic change. * atomic change.
*/ */
/**
* kfree_skb - free an sk_buff
* @skb: buffer to free
*
* Drop a reference to the buffer and free it if the usage count has
* hit zero.
*/
static inline void kfree_skb(struct sk_buff *skb)
{
if (likely(atomic_read(&skb->users) == 1))
smp_rmb();
else if (likely(!atomic_dec_and_test(&skb->users)))
return;
__kfree_skb(skb);
}
/** /**
* skb_cloned - is the buffer a clone * skb_cloned - is the buffer a clone
* @skb: buffer to check * @skb: buffer to check
......
...@@ -355,6 +355,24 @@ void __kfree_skb(struct sk_buff *skb) ...@@ -355,6 +355,24 @@ void __kfree_skb(struct sk_buff *skb)
kfree_skbmem(skb); kfree_skbmem(skb);
} }
/**
* kfree_skb - free an sk_buff
* @skb: buffer to free
*
* Drop a reference to the buffer and free it if the usage count has
* hit zero.
*/
void kfree_skb(struct sk_buff *skb)
{
if (unlikely(!skb))
return;
if (likely(atomic_read(&skb->users) == 1))
smp_rmb();
else if (likely(!atomic_dec_and_test(&skb->users)))
return;
__kfree_skb(skb);
}
/** /**
* skb_clone - duplicate an sk_buff * skb_clone - duplicate an sk_buff
* @skb: buffer to clone * @skb: buffer to clone
...@@ -1799,6 +1817,7 @@ void __init skb_init(void) ...@@ -1799,6 +1817,7 @@ void __init skb_init(void)
EXPORT_SYMBOL(___pskb_trim); EXPORT_SYMBOL(___pskb_trim);
EXPORT_SYMBOL(__kfree_skb); EXPORT_SYMBOL(__kfree_skb);
EXPORT_SYMBOL(kfree_skb);
EXPORT_SYMBOL(__pskb_pull_tail); EXPORT_SYMBOL(__pskb_pull_tail);
EXPORT_SYMBOL(__alloc_skb); EXPORT_SYMBOL(__alloc_skb);
EXPORT_SYMBOL(pskb_copy); EXPORT_SYMBOL(pskb_copy);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册