public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] [PKT_SCHED] RED: Fix overflow in calculation of queue average
Date: Thu, 3 Aug 2006 18:46:56 -0700	[thread overview]
Message-ID: <20060803184656.55da3939@localhost.localdomain> (raw)
In-Reply-To: <11546408123792-git-send-email-ilpo.jarvinen@helsinki.fi>

On Fri, 04 Aug 2006 00:33:32 +0300
Ilpo  Järvinen <ilpo.jarvinen@helsinki.fi> wrote:

> Overflow can occur very easily with 32 bits, e.g., with 1 second
> us_idle is approx. 2^20, which leaves only 11-Wlog bits for queue
> length. Since the EWMA exponent is typically around 9, queue
> lengths larger than 2^2 cause overflow. Whether the affected
> branch is taken when us_idle is as high as 1 second, depends on
> Scell_log, but with rather reasonable configuration Scell_log is
> large enough to cause p->Stab to have zero index, which always
> results zero shift (typically also few other small indices result
> in zero shift).
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
> ---
>  include/net/red.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/include/net/red.h b/include/net/red.h
> index 5ccdbb3..1fc32e1 100644
> --- a/include/net/red.h
> +++ b/include/net/red.h
> @@ -212,7 +212,7 @@ static inline unsigned long red_calc_qav
>  		 * Seems, it is the best solution to
>  		 * problem of too coarse exponent tabulation.
>  		 */
> -		us_idle = (p->qavg * us_idle) >> p->Scell_log;
> +		us_idle = (p->qavg * (long long)us_idle) >> p->Scell_log;
>  
>  		if (us_idle < (p->qavg >> 1))
>  			return p->qavg - us_idle;

Use u64 instead of long long. 

-- 
If one would give me six lines written by the hand of the most honest
man, I would find something in them to have him hanged. -- Cardinal Richlieu

  reply	other threads:[~2006-08-04  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03 21:33 [PATCH] [PKT_SCHED] RED: Fix overflow in calculation of queue average Ilpo  Järvinen
2006-08-04  1:46 ` Stephen Hemminger [this message]
2006-08-04 15:44   ` [PATCH v2] " Ilpo Järvinen
2006-08-04 23:36     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060803184656.55da3939@localhost.localdomain \
    --to=shemminger@osdl.org \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox