Skip to contentSkip to conversation

HTB_debug_dump: is annoying :) [Pach included]

LARTC Trevor Warren 3 participants 4 messages Jul 4, 2003 – Jul 5, 2003

lore
Share & tools
lore
#0 lore raw

Sorry Mike,

This isn't an answer to your queries but instead a question. I would
like to know if there are any added fields to the tc -s -d output post application of the 2.5 kernel patch you have applied below.

Cause i am using htb with 2.4.21 and there isn't much of graphing i can
do with the same. Especially no current rate parameter for HTB sub classes.

Trevor

Quoted 9 lines · Mike Mestnik

I use MRTG to graph tc -d output, so the debug_dump fills up my dmesg logs ect. It's just annoying.

Attached is a patch vs 2.5.74 and my MRTG script.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Signature · 9 lines
( >-        LINUX, It's all about CHOICE      -< )
/~\    __        [email protected]       __   /~\
|  \) /  Pre Sales Consultant - Red Hat     \ (/ |
|_|_  \    9820349221(M) | 22881326(O)      / _|_|
       \___________________________________/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
#1 lore raw

I use MRTG to graph tc -d output, so the debug_dump fills up my dmesg logs ect. It's just annoying.

Attached is a patch vs 2.5.74 and my MRTG script.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

sch_htb.c.myne renamed from sch_htb.c +13 -9
@@ -335,22 +335,22 @@
 	while (n->rb_left) n = n->rb_left; \
 	while (n) { \
 		struct htb_class *cl = rb_entry(n, struct htb_class, memb); \
-		printk(" %x",cl->classid); htb_next_rb_node (&n); \
+		HTB_DBG(0,3," %x",cl->classid); htb_next_rb_node (&n); \
 	} }
 
 static void htb_debug_dump (struct htb_sched *q)
 {
 	int i,p;
-	printk(KERN_DEBUG "htb*g j=%lu lj=%lu\n",jiffies,q->jiffies);
+	HTB_DBG(0,1,"htb*g j=%lu lj=%lu\n",jiffies,q->jiffies);
 	/* rows */
 	for (i=TC_HTB_MAXDEPTH-1;i>=0;i--) {
-		printk(KERN_DEBUG "htb*r%d m=%x",i,q->row_mask[i]);
+		HTB_DBG(0,2,"htb*r%d m=%x",i,q->row_mask[i]);
 		for (p=0;p<TC_HTB_NUMPRIO;p++) {
 			if (!q->row[i][p].rb_node) continue;
-			printk(" p%d:",p);
+			HTB_DBG(0,3," p%d:",p);
 			HTB_DUMTREE(q->row[i]+p,node[p]);
 		}
-		printk("\n");
+		HTB_DBG(0,2,"\n");
 	}
 	/* classes */
 	for (i = 0; i < HTB_HSIZE; i++) {
@@ -358,7 +358,7 @@
 		list_for_each (l,q->hash+i) {
 			struct htb_class *cl = list_entry(l,struct htb_class,hlist);
 			long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, 0);
-			printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d "
+			HTB_DBG(0,2,"htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d "
 					"pa=%x f:",
 				cl->classid,cl->cmode,cl->tokens,cl->ctokens,
 				cl->pq_node.rb_color==-1?0:cl->pq_key,diff,
@@ -366,10 +366,10 @@
 			if (cl->level)
 			for (p=0;p<TC_HTB_NUMPRIO;p++) {
 				if (!cl->un.inner.feed[p].rb_node) continue;
-				printk(" p%d a=%x:",p,cl->un.inner.ptr[p]?rb_entry(cl->un.inner.ptr[p], struct htb_class,node[p])->classid:0);
+				HTB_DBG(0,3," p%d a=%x:",p,cl->un.inner.ptr[p]?rb_entry(cl->un.inner.ptr[p], struct htb_class,node[p])->classid:0);
 				HTB_DUMTREE(cl->un.inner.feed+p,node[p]);
 			}
-			printk("\n");
+			HTB_DBG(0,2,"\n");
 		}
 	}
 }
@@ -994,6 +994,7 @@
 	struct htb_sched *q = (struct htb_sched *)sch->data;
 	int level;
 	long min_delay;
+	u32 debug_backup;
 #ifdef HTB_DEBUG
 	int evs_used = 0;
 #endif
@@ -1046,7 +1047,10 @@
 		if (min_delay == LONG_MAX) {
 			printk(KERN_ERR "HTB: dequeue bug (%d,%lu,%lu), report it please !\n",
 					evs_used,q->jiffies,jiffies);
+			debug_backup = q->debug;
+			q->debug>>(0) |= 3;
 			htb_debug_dump(q);
+			q->debug = debug_backup;
 		} else 
 			printk(KERN_WARNING "HTB: mindelay=%ld, some class has "
 					"too small rate\n",min_delay);
@@ -1188,7 +1192,7 @@
 	gopt.direct_pkts = q->direct_pkts;
 
 #ifdef HTB_DEBUG
-	htb_debug_dump(q);
+	if (((q->debug>>(0))&3) >= 1) htb_debug_dump(q);
 #endif
 	gopt.version = HTB_VER;
 	gopt.rate2quantum = q->rate2quantum;
#2 lore raw
In reply to Trevor Warren

No, the patch dose not affect tc only dmesg/klogd ect. It changes printk's into HTB_DBG macros, these macros don't print unless you set HTB into debug mode :)

The default kernel workes ?great? with my script 2.4.x and 2.5.x.

Here is an example...
The script workes like so... (10: is the qdisc-id)

filbert:~# /etc/network/mrtg.overlimits.pl 10: total,over
96320 <-- This is the total.
6630  <-- These are the overlimits (the total,over param dose this)
filbert:~# /etc/network/mrtg.overlimits.pl 10: total,over
96336
6654
filbert:~# /etc/network/mrtg.overlimits.pl 10: total,over
96359
6683
filbert:~# /etc/network/mrtg.overlimits.pl 10: total,over
96373
6705

mrtg.cfg lookes like this.
#############################################################
#
#

Target[toverlimits]: /etc/network/mrtg.overlimits.pl 10: total,over MaxBytes[toverlimits]: 6400
AbsMax[toverlimits]: 640000
WithPeak[toverlimits]: wmy
Options[toverlimits]: noinfo, perminute
YLegend[toverlimits]: Packets/Minute
ShortLegend[toverlimits]: p/min
Legend1[toverlimits]: Sent Traffic in Packets per Minute Legend2[toverlimits]: Overlimit Traffic in Packets per Minute Legend3[toverlimits]: Maximal 5 Minute Sent Traffic Legend4[toverlimits]: Maximal 5 Minute Overlimit Traffic LegendI[toverlimits]: &nbsp;Sent:
LegendO[toverlimits]: &nbsp;Overlimit:
Title[toverlimits]: Root Qdisc Sent/Overlimits on Internet Pipe -- Filbert PageTop[toverlimits]: <H1>Root Qdisc Sent/Overlimits on Internet Pipe -- Filbert</H1>
<TABLE>
<TR><TD>System:</TD> <TD>Filbert (Main Router and Moms PC)</TD></TR>
<TR><TD>Maintainer:</TD> <TD>Cheako [email protected]</TD></TR> <TR><TD>Description:</TD><TD>Sent/Overlimits on Internet Pipe</TD></TR>
</TABLE>

#-------------------------------------------------------------------

You can see my graphs at http://filbert.is-a-geek.org/mrtg/

P.N. The original patch I sent in had one bug, theres a part that lookes like this "q->debug>>(0) |= 3;"
It needed to look like this. "debug_backup = q->debug;"

@@ -1046,7 +1047,10 @@

                if (min_delay = LONG_MAX) {
                        printk(KERN_ERR "HTB: dequeue bug (%d,%lu,%lu), report it please !\n",
                                        evs_used,q->jiffies,jiffies);
+                       debug_backup = q->debug;
+                       q->debug |= 3>>(0);
                        htb_debug_dump(q);
+                       q->debug = debug_backup;
                } else
                        printk(KERN_WARNING "HTB: mindelay=%ld, some class has "
                                        "too small rate\n",min_delay);
Quoted 17 lines · --- Trevor Warren

Sorry Mike,

This isn't an answer to your queries but instead a question. I would
like to know if there are any added fields to the tc -s -d output post application of the 2.5 kernel patch you have applied below.

Cause i am using htb with 2.4.21 and there isn't much of graphing i can
do with the same. Especially no current rate parameter for HTB sub classes.

Trevor

Quoted 3 lines · Mike Mestnik

I use MRTG to graph tc -d output, so the debug_dump fills up my dmesg logs ect. It's just annoying.

Quoted 13 lines
Quoted 6 lines

Attached is a patch vs 2.5.74 and my MRTG script.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Signature · 5 lines
( >-        LINUX, It's all about CHOICE      -< )
/~\    __        [email protected]       __   /~\
|  \) /  Pre Sales Consultant - Red Hat     \ (/ |
|_|_  \    9820349221(M) | 22881326(O)      / _|_|
       \___________________________________/

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#3 lore raw
In reply to Trevor Warren

And what about attached one ? It seems to do the same but is less intrusive. htb_debug_dump is meant to do its output in all cases because it is called from bug-reporting places too.
But yes the call in htb_dump is superfluous so I used your idea but changed it a bit. I'll submit it for inclusion latter.

thanks,
-------------------------------
Martin Devera aka devik
Linux kernel QoS/HTB maintainer
http://luxik.cdi.cz/~devik/

Quoted 13 lines · Mike Mestnik
Quoted 9 lines

I use MRTG to graph tc -d output, so the debug_dump fills up my dmesg logs ect. It's just annoying.

Attached is a patch vs 2.5.74 and my MRTG script.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

--
( >- LINUX, It's all about CHOICE -< )
/~\ __ [email protected] __ /~\

Quoted 9 lines
|  \) /  Pre Sales Consultant - Red Hat     \ (/ |
|_|_  \    9820349221(M) | 22881326(O)      / _|_|
       \___________________________________/

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

sch_htb.c +6 -3
@@ -21,7 +21,7 @@
  *			created test case so that I was able to fix nasty bug
  *		and many others. thanks.
  *
- * $Id: sch_htb.c,v 1.20 2003/06/18 19:55:49 devik Exp $
+ * $Id: sch_htb.c,v 1.21 2003/07/05 10:37:11 devik Exp devik $
  */
 #include <linux/config.h>
 #include <linux/module.h>
@@ -98,7 +98,8 @@
  from LSB
  */
 #ifdef HTB_DEBUG
-#define HTB_DBG(S,L,FMT,ARG...) if (((q->debug>>(2*S))&3) >= L) \
+#define HTB_DBG_COND(S,L) (((q->debug>>(2*S))&3) >= L)
+#define HTB_DBG(S,L,FMT,ARG...) if (HTB_DBG_COND(S,L)) \
 	printk(KERN_DEBUG FMT,##ARG)
 #define HTB_CHCL(cl) BUG_TRAP((cl)->magic == HTB_CMAGIC)
 #define HTB_PASSQ q,
@@ -114,6 +115,7 @@
 		rb_erase(N,R); \
 		(N)->rb_color = -1; } while (0)
 #else
+#define HTB_DBG_COND(S,L) (0)
 #define HTB_DBG(S,L,FMT,ARG...)
 #define HTB_PASSQ
 #define HTB_ARGQ
@@ -1202,7 +1204,8 @@ static int htb_dump(struct Qdisc *sch, s
 	gopt.direct_pkts = q->direct_pkts;
 
 #ifdef HTB_DEBUG
-	htb_debug_dump(q);
+	if (HTB_DBG_COND(0,2))
+		htb_debug_dump(q);
 #endif
 	gopt.version = HTB_VER;
 	gopt.rate2quantum = q->rate2quantum;