From: Patrick McHardy <kaber@trash.net>
To: netdev@vger.kernel.org
Cc: devik@cdi.cz, Patrick McHardy <kaber@trash.net>, jarkao2@gmail.com
Subject: net-sched 04/06: sch_htb: move hash and sibling list removal to htb_delete
Date: Thu, 3 Jul 2008 17:16:06 +0200 (MEST) [thread overview]
Message-ID: <20080703151606.26225.61647.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080703151600.26225.3394.sendpatchset@localhost.localdomain>
net-sched: sch_htb: move hash and sibling list removal to htb_delete
Hash list removal currently happens twice (once in htb_delete, once
in htb_destroy_class), which makes it harder to use the dynamically
sized class hash without adding special cases for HTB. The reason is
that qdisc destruction destroys classes in hierarchical order, which
is not necessary if filters are destroyed in a separate iteration
during qdisc destruction.
Adjust qdisc destruction to follow the same scheme as other hierarchical
qdiscs by first performing a filter destruction pass, then destroying
all classes in hash order.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 3fcfd66ab1737d4bcb2158866d7b2b574b0099bf
tree 9146a96a6353464ef6a42706ad5bc4a7c8ce92d2
parent 7ce0dc13a43a80bcce1dc862f35fddc9740aaf27
author Patrick McHardy <kaber@trash.net> Thu, 03 Jul 2008 16:58:46 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 03 Jul 2008 16:58:46 +0200
net/sched/sch_htb.c | 40 +++++++++++++++++-----------------------
1 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 0284791..d01fe3a 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1226,8 +1226,6 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
{
- struct htb_sched *q = qdisc_priv(sch);
-
if (!cl->level) {
BUG_TRAP(cl->un.leaf.q);
qdisc_destroy(cl->un.leaf.q);
@@ -1237,21 +1235,6 @@ static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
qdisc_put_rtab(cl->ceil);
tcf_destroy_chain(&cl->filter_list);
-
- while (!list_empty(&cl->children))
- htb_destroy_class(sch, list_entry(cl->children.next,
- struct htb_class, sibling));
-
- /* note: this delete may happen twice (see htb_delete) */
- hlist_del_init(&cl->hlist);
- list_del(&cl->sibling);
-
- if (cl->prio_activity)
- htb_deactivate(q, cl);
-
- if (cl->cmode != HTB_CAN_SEND)
- htb_safe_rb_erase(&cl->pq_node, q->wait_pq + cl->level);
-
kfree(cl);
}
@@ -1259,6 +1242,9 @@ static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
static void htb_destroy(struct Qdisc *sch)
{
struct htb_sched *q = qdisc_priv(sch);
+ struct hlist_node *n, *next;
+ struct htb_class *cl;
+ unsigned int i;
qdisc_watchdog_cancel(&q->watchdog);
/* This line used to be after htb_destroy_class call below
@@ -1267,10 +1253,14 @@ static void htb_destroy(struct Qdisc *sch)
unbind_filter on it (without Oops). */
tcf_destroy_chain(&q->filter_list);
- while (!list_empty(&q->root))
- htb_destroy_class(sch, list_entry(q->root.next,
- struct htb_class, sibling));
-
+ for (i = 0; i < HTB_HSIZE; i++) {
+ hlist_for_each_entry(cl, n, q->hash + i, hlist)
+ tcf_destroy_chain(&cl->filter_list);
+ }
+ for (i = 0; i < HTB_HSIZE; i++) {
+ hlist_for_each_entry_safe(cl, n, next, q->hash + i, hlist)
+ htb_destroy_class(sch, cl);
+ }
__skb_queue_purge(&q->direct_queue);
}
@@ -1302,12 +1292,16 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
qdisc_tree_decrease_qlen(cl->un.leaf.q, qlen);
}
- /* delete from hash and active; remainder in destroy_class */
- hlist_del_init(&cl->hlist);
+ /* delete from hash, sibling list and active */
+ hlist_del(&cl->hlist);
+ list_del(&cl->sibling);
if (cl->prio_activity)
htb_deactivate(q, cl);
+ if (cl->cmode != HTB_CAN_SEND)
+ htb_safe_rb_erase(&cl->pq_node, q->wait_pq + cl->level);
+
if (last_child)
htb_parent_to_leaf(q, cl, new_q);
next prev parent reply other threads:[~2008-07-03 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-03 15:16 net-sched 00/06: dynamically sized class hashes v2 Patrick McHardy
2008-07-03 15:16 ` net-sched 01/06: add dynamically sized qdisc class hash helpers Patrick McHardy
2008-07-03 15:16 ` net-sched 02/06: sch_hfsc: use dynamic " Patrick McHardy
2008-07-03 15:16 ` net-sched 03/06: sch_cbq: " Patrick McHardy
2008-07-03 15:16 ` Patrick McHardy [this message]
2008-07-03 15:16 ` net-sched 05/06: sch_htb: " Patrick McHardy
2008-07-03 15:16 ` net-sched 06/06: sch_htb: remove child and sibling lists Patrick McHardy
2008-07-03 16:14 ` net-sched 00/06: dynamically sized class hashes v2 Jarek Poplawski
2008-07-03 16:09 ` Patrick McHardy
2008-07-03 16:46 ` Jarek Poplawski
2008-07-03 16:49 ` Patrick McHardy
2008-07-04 12:20 ` net-sched 07/06: sch_htb: remove write-only qdisc filter_cnt Patrick McHardy
2008-07-04 14:29 ` Jarek Poplawski
2008-07-06 6:28 ` David Miller
2008-07-06 6:28 ` net-sched 00/06: dynamically sized class hashes v2 David Miller
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=20080703151606.26225.61647.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=devik@cdi.cz \
--cc=jarkao2@gmail.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).