From: Jarek Poplawski <jarkao2@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: Jan 'yanek' Bortl <yanek@ya.bofh.cz>, netdev@vger.kernel.org
Subject: [PATCH][NET_SCHED] sch_htb: remove from event queue in htb_parent_to_leaf()
Date: Sat, 3 May 2008 20:42:45 +0200 [thread overview]
Message-ID: <20080503184245.GB6484@ami.dom.local> (raw)
In-Reply-To: <481CA037.3000909@ya.bofh.cz>
On Sat, May 03, 2008 at 07:26:15PM +0200, Jan 'yanek' Bortl wrote:
> Jarek Poplawski wrote:
>> ...
>>
>> Here is a suspect #1. (BTW, this place reminds me something...)
>
> Great! Seems to solve my problem. I'll do some tests.
Hi David,
IMHO this patch is needed even if there is something more.
Thanks,
Jarek P.
-------------------->
[NET_SCHED] sch_htb: remove from event queue in htb_parent_to_leaf()
There is lack of removing a class from the event queue while changing
from parent to leaf which can cause corruption of this rb tree. This
patch fixes a bug introduced by my patch: "sch_htb: turn intermediate
classes into leaves" commit: 160d5e10f87b1dc88fd9b84b31b1718e0fd76398.
Many thanks to Jan 'yanek' Bortl for finding a way to reproduce this
rare bug and narrowing the test case, which made possible proper
diagnosing.
This patch is recommended for all kernels starting from 2.6.20.
Reported-and-tested-by: Jan 'yanek' Bortl <yanek@ya.bofh.cz>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
---
net/sched/sch_htb.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 66148cc..5bc1ed4 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1197,12 +1197,16 @@ static inline int htb_parent_last_child(struct htb_class *cl)
return 1;
}
-static void htb_parent_to_leaf(struct htb_class *cl, struct Qdisc *new_q)
+static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
+ struct Qdisc *new_q)
{
struct htb_class *parent = cl->parent;
BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity);
+ if (parent->cmode != HTB_CAN_SEND)
+ htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level);
+
parent->level = 0;
memset(&parent->un.inner, 0, sizeof(parent->un.inner));
INIT_LIST_HEAD(&parent->un.leaf.drop_list);
@@ -1300,7 +1304,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
htb_deactivate(q, cl);
if (last_child)
- htb_parent_to_leaf(cl, new_q);
+ htb_parent_to_leaf(q, cl, new_q);
if (--cl->refcnt == 0)
htb_destroy_class(sch, cl);
next prev parent reply other threads:[~2008-05-03 18:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-01 15:49 PROBLEM: kernel lockup while changing TC rules Jan 'yanek' Bortl
2008-05-03 7:16 ` Jarek Poplawski
2008-05-03 9:43 ` Jan 'yanek' Bortl
2008-05-03 12:11 ` Jarek Poplawski
2008-05-03 12:42 ` Jan 'yanek' Bortl
2008-05-03 16:39 ` Jarek Poplawski
2008-05-03 17:26 ` Jan 'yanek' Bortl
2008-05-03 18:42 ` Jarek Poplawski [this message]
2008-05-04 1:58 ` [PATCH][NET_SCHED] sch_htb: remove from event queue in htb_parent_to_leaf() 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=20080503184245.GB6484@ami.dom.local \
--to=jarkao2@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=yanek@ya.bofh.cz \
/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).