Subject: Re: [PATCH] sch_htb.c consume the classes's tokens bellow the HTB_CAN_SEND level

From: Jarek Poplawski <[email-masked]>
Date: Tue, 3 Nov 2009 08:00:22 +0000

On 03-11-2009 03:41, Changli Gao wrote:
> sch_htb.c consume the classes's tokens bellow the HTB_CAN_SEND level.
> 
> When a class enters HTB_MAY_BORROW state, it relies on its parents to
> sent packets. The parent class in HTB_CAN_SEND state only consumes
> itself and its parents's tokens, but ADD tokens to the classes under its
> level. It is totally wrong.

Current code is OK.

> It means that a class, which sends packets
> in ceil rate, can also enter HTB_CAN_SEND state now and then.

Yes, a class is entitled to send on it's own then with it's guaranteed
rate, without depending on borrowing.

Jarek P.

> 
> Signed-off-by: Changli Gao <[email-masked]>
> 
> ----
> net/sched/sch_htb.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 85acab9..2705702 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -629,11 +629,10 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl,
>  		if (cl->level >= level) {
>  			if (cl->level == level)
>  				cl->xstats.lends++;
> -			htb_accnt_tokens(cl, bytes, diff);
>  		} else {
>  			cl->xstats.borrows++;
> -			cl->tokens += diff;	/* we moved t_c; update tokens */
>  		}
> +		htb_accnt_tokens(cl, bytes, diff);
>  		htb_accnt_ctokens(cl, bytes, diff);
>  		cl->t_c = q->now;
>