From: Patrick McHardy <kaber@trash.net>
To: Martin Devera <devik@cdi.cz>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [RFC]: net-sched 00/05: dynamically sized class hashes
Date: Wed, 02 Jul 2008 16:21:03 +0200 [thread overview]
Message-ID: <486B8ECF.3070604@trash.net> (raw)
In-Reply-To: <486B54B7.2060100@trash.net>
[-- Attachment #1: Type: text/plain, Size: 462 bytes --]
Patrick McHardy wrote:
> Martin Devera wrote:
>> Interestingly, once you do this patch then children/siblings list-heads
>> are used only in htb_parent_last_child and to detect empty class.
>> Thus we could remove children/siblings lists altogether ane keep only
>> children counter.
>> I can't believe it is so simple, what do you think, Patrick ?
>
> Yes, it looks like that would work. I'll give it a try :)
How about this, on top of my previous patches?
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 2730 bytes --]
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 4fc866d..bb1c210 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -81,9 +81,8 @@ struct htb_class {
/* topology */
int level; /* our level (see above) */
+ unsigned int children;
struct htb_class *parent; /* parent class */
- struct list_head sibling; /* sibling list item */
- struct list_head children; /* children list */
union {
struct htb_class_leaf {
@@ -138,7 +137,6 @@ static inline long L2T(struct htb_class *cl, struct qdisc_rate_table *rate,
}
struct htb_sched {
- struct list_head root; /* root classes list */
struct Qdisc_class_hash clhash;
struct list_head drops[TC_HTB_NUMPRIO];/* active leaves (for drops) */
@@ -1022,7 +1020,6 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
return -EINVAL;
}
- INIT_LIST_HEAD(&q->root);
err = qdisc_class_hash_init(&q->clhash);
if (err < 0)
return err;
@@ -1177,12 +1174,9 @@ static inline int htb_parent_last_child(struct htb_class *cl)
if (!cl->parent)
/* the root class */
return 0;
-
- if (!(cl->parent->children.next == &cl->sibling &&
- cl->parent->children.prev == &cl->sibling))
+ if (cl->parent->children > 1)
/* not the last child */
return 0;
-
return 1;
}
@@ -1266,7 +1260,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
// TODO: why don't allow to delete subtree ? references ? does
// tc subsys quarantee us that in htb_destroy it holds no class
// refs so that we can remove children safely there ?
- if (!list_empty(&cl->children) || cl->filter_cnt)
+ if (cl->children || cl->filter_cnt)
return -EBUSY;
if (!cl->level && htb_parent_last_child(cl)) {
@@ -1285,7 +1279,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
/* delete from hash and active; remainder in destroy_class */
qdisc_class_hash_remove(&q->clhash, &cl->common);
- list_del(&cl->sibling);
+ cl->parent->children--;
if (cl->prio_activity)
htb_deactivate(q, cl);
@@ -1380,8 +1374,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
&sch->dev->queue_lock,
tca[TCA_RATE] ? : &est.nla);
cl->refcnt = 1;
- INIT_LIST_HEAD(&cl->sibling);
- INIT_LIST_HEAD(&cl->children);
+ cl->children = 0;
INIT_LIST_HEAD(&cl->un.leaf.drop_list);
RB_CLEAR_NODE(&cl->pq_node);
@@ -1427,8 +1420,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
/* attach to the hash list and parent's family */
qdisc_class_hash_insert(&q->clhash, &cl->common);
- list_add_tail(&cl->sibling,
- parent ? &parent->children : &q->root);
+ if (parent)
+ parent->children++;
} else {
if (tca[TCA_RATE])
gen_replace_estimator(&cl->bstats, &cl->rate_est,
next prev parent reply other threads:[~2008-07-02 14:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-01 14:34 [RFC]: net-sched 00/05: dynamically sized class hashes Patrick McHardy
2008-07-01 14:34 ` net-sched 01/05: add dynamically sized qdisc class hash helpers Patrick McHardy
2008-07-03 12:18 ` Jarek Poplawski
2008-07-03 12:16 ` Patrick McHardy
2008-07-01 14:34 ` net-sched 02/05: sch_hfsc: use dynamic " Patrick McHardy
2008-07-01 14:34 ` net-sched 03/05: sch_cbq: " Patrick McHardy
2008-07-01 14:34 ` net-sched 04/05: sch_htb: move hash and sibling list removal to htb_delete Patrick McHardy
2008-07-02 8:15 ` Jarek Poplawski
2008-07-02 10:11 ` Patrick McHardy
2008-07-02 12:16 ` Jarek Poplawski
2008-07-02 12:25 ` Patrick McHardy
2008-07-02 21:14 ` Jarek Poplawski
2008-07-03 11:53 ` Patrick McHardy
2008-07-01 14:34 ` net-sched 05/05: sch_htb: use dynamic class hash helpers Patrick McHardy
2008-07-02 21:31 ` Jarek Poplawski
2008-07-03 11:55 ` Patrick McHardy
2008-07-02 2:50 ` [RFC]: net-sched 00/05: dynamically sized class hashes David Miller
2008-07-02 6:54 ` Martin Devera
2008-07-02 10:13 ` Patrick McHardy
2008-07-02 14:21 ` Patrick McHardy [this message]
2008-07-02 14:27 ` Martin Devera
2008-07-02 14:30 ` Patrick McHardy
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=486B8ECF.3070604@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=devik@cdi.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.