Skip to content

Commit

Permalink
net: speed up skb_rbtree_purge()
Browse files Browse the repository at this point in the history
commit 7c90584 upstream.

As measured in my prior patch ("sch_netem: faster rb tree removal"),
rbtree_postorder_for_each_entry_safe() is nice looking but much slower
than using rb_next() directly, except when tree is small enough
to fit in CPU caches (then the cost is the same)

Also note that there is not even an increase of text size :
$ size net/core/skbuff.o.before net/core/skbuff.o
   text	   data	    bss	    dec	    hex	filename
  40711	   1298	      0	  42009	   a419	net/core/skbuff.o.before
  40711	   1298	      0	  42009	   a419	net/core/skbuff.o

From: Eric Dumazet <edumazet@google.com>

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Eric Dumazet authored and Greg Kroah-Hartman committed Jan 26, 2019
1 parent e660576 commit de61497
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2388,12 +2388,15 @@ EXPORT_SYMBOL(skb_queue_purge);
*/
void skb_rbtree_purge(struct rb_root *root)
{
struct sk_buff *skb, *next;
struct rb_node *p = rb_first(root);

rbtree_postorder_for_each_entry_safe(skb, next, root, rbnode)
kfree_skb(skb);
while (p) {
struct sk_buff *skb = rb_entry(p, struct sk_buff, rbnode);

*root = RB_ROOT;
p = rb_next(p);
rb_erase(&skb->rbnode, root);
kfree_skb(skb);
}
}

/**
Expand Down

0 comments on commit de61497

Please sign in to comment.