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

From: Jarek Poplawski <[email-masked]>
Date: Tue, 1 Dec 2009 09:39:23 +0000

On Tue, Dec 01, 2009 at 05:18:32PM +0800, Changli Gao wrote:
> On Tue, Dec 1, 2009 at 4:43 PM, Jarek Poplawski <[email-masked]> wrote:
> > On Tue, Dec 01, 2009 at 08:01:51AM +0000, Jarek Poplawski wrote:
> >> On Tue, Dec 01, 2009 at 10:32:26AM +0800, Changli Gao wrote:
> >> > On Mon, Nov 30, 2009 at 7:10 PM, Jarek Poplawski <[email-masked]> wrote:
> > ...
> >> > > And this patch is very similar, except ->peek()/dequeue(). Additional
> >> > > lookups are done instead of dequeuing the first found class, which
> >> > > might be quite long in some cases.
> >> >
> >> > If the quantum is set correctly, there isn't difference except of a
> >> > comparison. In the other case, I think some additional CPU cycles are
> >> > better than overflow.
> >>
> >> No, my main point is there _is_ a difference when the quantum is set
> >> correctly. Just these additional lookups.
> >
> > 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;
> 
> How about this:
>          if (cl->un.leaf.deficit[level] < 0) {
>                 cl->un.leaf.deficit[level] = 0;
>                 if (!(cl->warned & HTB_WARN_QUANTUM_SMALL)) {
>                         printk(KERN_WARNING
>                                "HTB: quantum of class %X is small.
> Consider r2q change.\n",
>                                cl->common.classid);
>                     cl->warned |= HTB_WARN_QUANTUM_SMALL;
>                 }
>          }

I guess you mean q->warned. Maybe unlikely() would be useful too.
Otherwise, it's acceptable to me, especially when you write you really
hit this problem (not theoretical only ;-)

Jarek P.