From: Mao Wenan <maowenan@huawei.com>
To: <gregkh@linux-foundation.org>, <stable@vger.kernel.org>,
<edumazet@google.com>, <netdev@vger.kernel.org>,
<davem@davemloft.net>, <maowenan@huawei.com>,
<eric.dumazet@gmail.com>
Subject: [PATCH stable 4.4 v2 01/11] net: speed up skb_rbtree_purge()
Date: Fri, 25 Jan 2019 10:48:34 +0800 [thread overview]
Message-ID: <1548384524-174152-2-git-send-email-maowenan@huawei.com> (raw)
In-Reply-To: <1548384524-174152-1-git-send-email-maowenan@huawei.com>
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 7c90584c66cc4b033a3b684b0e0950f79e7b7166 ]
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>
---
net/core/skbuff.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 9703924..8a57bba 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -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);
+ }
}
/**
--
1.8.3.1
next prev parent reply other threads:[~2019-01-25 2:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 2:48 [PATCH stable 4.4 v2 00/11] fix FragmentSmack in stable branch (CVE-2018-5391) Mao Wenan
2019-01-25 2:48 ` Mao Wenan [this message]
2019-01-25 2:48 ` [PATCH stable 4.4 v2 02/11] ip: discard IPv4 datagrams with overlapping segments Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 03/11] net: modify skb_rbtree_purge to return the truesize of all purged skbs Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 04/11] inet: frags: get rif of inet_frag_evicting() Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 05/11] ip: use rb trees for IP frag queue Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 06/11] ipv6: defrag: drop non-last frags smaller than min mtu Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 07/11] ip: add helpers to process in-order fragments faster Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 08/11] ip: process in-order fragments efficiently Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 09/11] net: ipv4: do not handle duplicate fragments as overlapping Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 10/11] ip: frags: fix crash in ip_do_fragment() Mao Wenan
2019-01-25 2:48 ` [PATCH stable 4.4 v2 11/11] ipv4: frags: precedence bug in ip_expire() Mao Wenan
2019-02-04 10:03 ` [PATCH stable 4.4 v2 00/11] fix FragmentSmack in stable branch (CVE-2018-5391) Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1548384524-174152-2-git-send-email-maowenan@huawei.com \
--to=maowenan@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=gregkh@linux-foundation.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox