net_sched: make qdisc_reset() smaller
Subsystems (3)
PATCH 1/1 net_sched: make qdisc_reset() smaller
From: Eric Dumazet <[email protected]>
For some unknown reason qdisc_reset() is using
a convoluted way of freeing two lists of skbs.
Use __skb_queue_purge() instead.
--- net/sched/sch_generic.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
net/sched/sch_generic.c +2 -10
@@ -1019,22 +1019,14 @@ EXPORT_SYMBOL(qdisc_create_dflt);void qdisc_reset (struct Qdisc *qdisc) {const struct Qdisc_ops *ops = qdisc->ops; -struct sk_buff *skb, *tmp;trace_qdisc_reset (qdisc);if (ops->reset) ops->reset (qdisc); - skb_queue_walk_safe(&qdisc->gso_skb, skb, tmp) { -__skb_unlink (skb, &qdisc->gso_skb); -kfree_skb_list (skb); - } - - skb_queue_walk_safe(&qdisc->skb_bad_txq, skb, tmp) { -__skb_unlink (skb, &qdisc->skb_bad_txq); -kfree_skb_list (skb); - } +__skb_queue_purge (&qdisc->gso_skb); +__skb_queue_purge (&qdisc->skb_bad_txq); qdisc->q.qlen =0 ; qdisc->qstats.backlog =0 ;
Signature · 1 line
2.35.1.1178.g4f1659d476-goog
Quoted 29 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For some unknown reason
qdisc_reset()is using
a convoluted way of freeing two lists of skbs.Use
__skb_queue_purge()instead.Signed-off-by Eric Dumazet <[email protected]>--- net/sched/sch_generic.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)net/sched/sch_generic.c +0
-3@@ -1019,22 +1019,14 @@ EXPORT_SYMBOL(qdisc_create_dflt);void qdisc_reset (struct Qdisc *qdisc) {const struct Qdisc_ops *ops = qdisc->ops; -struct sk_buff *skb, *tmp;trace_qdisc_reset (qdisc);if (ops->reset) ops->reset (qdisc); - skb_queue_walk_safe(&qdisc->gso_skb, skb, tmp) { -__skb_unlink (skb, &qdisc->gso_skb);
net/sched/sch_generic.c EXPORT_SYMBOL(qdisc_create_dflt); · line 1030
Quoted 10 lines
net/sched/sch_generic.c +2
-7-kfree_skb_list (skb); - } - - skb_queue_walk_safe(&qdisc->skb_bad_txq, skb, tmp) { -__skb_unlink (skb, &qdisc->skb_bad_txq); -kfree_skb_list (skb); - } +__skb_queue_purge (&qdisc->gso_skb); +__skb_queue_purge (&qdisc->skb_bad_txq);
cheers,
jamal
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 13 Apr 2022 18:10:04 -0700 you wrote:
From: Eric Dumazet <[email protected]>
For some unknown reason
qdisc_reset()is using
a convoluted way of freeing two lists of skbs.Use
__skb_queue_purge()instead.[...]
Here is the summary with links:
- [net-next] net_sched: make qdisc_reset() smaller
https://git.kernel.org/netdev/net-next/c/c9a40d1c87e9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 7 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For some unknown reason
qdisc_reset()is using
a convoluted way of freeing two lists of skbs.Use
__skb_queue_purge()instead.
[...]
net/sched/sch_generic.c EXPORT_SYMBOL(qdisc_create_dflt); · line 1031
Quoted 4 lines
net/sched/sch_generic.c +0
-3- skb_queue_walk_safe(&qdisc->gso_skb, skb, tmp) { -__skb_unlink (skb, &qdisc->gso_skb); -kfree_skb_list (skb);
Isn't it precisely because of this kfree_skb_list()?
Thanks.
Quoted 8 lines · Cong Wang
Quoted 6 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
For some unknown reason
qdisc_reset()is using
a convoluted way of freeing two lists of skbs.
Quoted 8 lines
Quoted 1 line
Use
__skb_queue_purge()instead.[...]
net/sched/sch_generic.c EXPORT_SYMBOL(qdisc_create_dflt); · line 1031
Quoted 4 lines
net/sched/sch_generic.c +0
-3- skb_queue_walk_safe(&qdisc->gso_skb, skb, tmp) { -__skb_unlink (skb, &qdisc->gso_skb); -kfree_skb_list (skb);Isn't it precisely because of this
kfree_skb_list()?
Note the __skb_unlink(skb, &qdisc->gso_skb) which happens at the line above.
__skb_unlink(...)
{
...skb->next = skb->prev = NULL;
...
}
This means skb->next is NULL, thus there is no list of skb attached to @skb ?
kfree_skb_list(skb) is thus a convoluted way to call kfree_skb(skb)
It seems to me that this construct had been copy/pasted from elsewhere.