Subject: Re: [PATCH] sch_htb: ix the deficit overflows

From: Jarek Poplawski <[email-masked]>
Date: Tue, 01 Dec 2009 20:12:20 +0100

Jarek Poplawski wrote, On 12/01/2009 09:43 AM:

> And, again, there are less invasive ways to fix such overflow, like
> 
> htb_dequeue_tree()
> {
> ...
>         if (likely(skb != NULL)) {
>                 cl->un.leaf.deficit[level] -= qdisc_pkt_len(skb);
>                 if (cl->un.leaf.deficit[level] < 0) {
>                         cl->un.leaf.deficit[level] += cl->quantum;
> 
> +                	if (cl->un.leaf.deficit[level] < 0)
> +                        	cl->un.leaf.deficit[level] = -cl->quantum;
> +				/* or other limit */
> 
>                         htb_next_rb_node((level ? cl->parent->un.inner.ptr : q->
>                                           ptr[0]) + prio);
>                 }
>                 /* this used to be after charge_class but this constelation
>                    gives us slightly better performance */
>                 if (!cl->un.leaf.q->q.qlen)
>                         htb_deactivate(q, cl);
>                 htb_charge_class(q, cl, level, skb);
>         }
>         return skb;
> }
> 
> or even always zeroing cl->un.leaf.deficit[level] on activation or
> deactivation (it's seems unlikely one activity period is enough for
> such an overflow).

So, as I wrote before, your proposal based on the first variant is
acceptable to me, but please reconsider the second idea too, e.g.
done like this:

                 }
                 /* this used to be after charge_class but this constelation
                    gives us slightly better performance */
                 if (!cl->un.leaf.q->q.qlen) {
                         htb_deactivate(q, cl);
+			 if (unlikely(cl->un.leaf.deficit[level] < cl->quantum)) {
+				{ a warning }
+                      	 	cl->un.leaf.deficit[level] = 0;
+			 }
 		 }
                 htb_charge_class(q, cl, level, skb);
         }
         return skb;
 }

Jarek P.