lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1386245932.30495.169.camel@edumazet-glaptop2.roam.corp.google.com>
Date:	Thu, 05 Dec 2013 04:18:52 -0800
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Yang Yingliang <yangyingliang@...wei.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org, brouer@...hat.com,
	jpirko@...hat.com, jbrouer@...hat.com
Subject: Re: [PATCH net v5 2/2] net: sched: htb: fix calculation of quantum

On Thu, 2013-12-05 at 15:10 +0800, Yang Yingliang wrote:
> Now, 32bit rates may be not the true rate.
> So use rate_bytes_ps which is from
> max(rate32, rate64) to calcualte quantum.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
> Acked-by: Eric Dumazet <edumazet@...gle.com>
> ---
>  net/sched/sch_htb.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
> index 0e1e38b..57c6678 100644
> --- a/net/sched/sch_htb.c
> +++ b/net/sched/sch_htb.c
> @@ -1477,11 +1477,20 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
>  		sch_tree_lock(sch);
>  	}
>  
> +	rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
> +
> +	ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
> +
> +	psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
> +	psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
> +
>  	/* it used to be a nasty bug here, we have to check that node
>  	 * is really leaf before changing cl->un.leaf !
>  	 */
>  	if (!cl->level) {
> -		cl->quantum = hopt->rate.rate / q->rate2quantum;
> +		u64 quantum = div64_u64(cl->rate.rate_bytes_ps,
> +					q->rate2quantum);

		q->rate2quantum being 32bit, prefer the following :

		u64 quantum = cl->rate.rate_bytes_ps;

		do_div(quantum, q->rate2quantum);

		Since it maps to better assembly code on 32bit arches.

> +		cl->quantum = min_t(u64, quantum, INT_MAX);
>  		if (!hopt->quantum && cl->quantum < 1000) {
>  			pr_warning(
>  			       "HTB: quantum of class %X is small. Consider r2q change.\n",
> @@ -1500,13 +1509,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
>  			cl->prio = TC_HTB_NUMPRIO - 1;
>  	}
>  
> -	rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
> -
> -	ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
> -
> -	psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
> -	psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
> -
>  	cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
>  	cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer);
>  


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ