Commit 654cb183 authored by Eric Dumazet's avatar Eric Dumazet Committed by Stefan Bader

net: speed up skb_rbtree_purge()

BugLink: https://bugs.launchpad.net/bugs/1818797

commit 7c90584c 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: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarMao Wenan <maowenan@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent a1603304
...@@ -2459,12 +2459,15 @@ EXPORT_SYMBOL(skb_queue_purge); ...@@ -2459,12 +2459,15 @@ EXPORT_SYMBOL(skb_queue_purge);
*/ */
void skb_rbtree_purge(struct rb_root *root) 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) while (p) {
kfree_skb(skb); 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);
}
} }
/** /**
......
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