netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [PKT_SCHED] RED: Fix overflow in calculation of queue average
@ 2006-08-03 21:33 Ilpo  Järvinen
  2006-08-04  1:46 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Ilpo  Järvinen @ 2006-08-03 21:33 UTC (permalink / raw)
  To: netdev; +Cc: Ilpo  Järvinen

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;
-- 
1.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [PKT_SCHED] RED: Fix overflow in calculation of queue average
  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
  2006-08-04 15:44   ` [PATCH v2] " Ilpo Järvinen
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2006-08-04  1:46 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: netdev

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] [PKT_SCHED] RED: Fix overflow in calculation of queue average
  2006-08-04  1:46 ` Stephen Hemminger
@ 2006-08-04 15:44   ` Ilpo Järvinen
  2006-08-04 23:36     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ilpo Järvinen @ 2006-08-04 15:44 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

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 2ed4358..cfc2625 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -213,7 +213,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 * (u64)us_idle) >> p->Scell_log;
 
 		if (us_idle < (p->qavg >> 1))
 			return p->qavg - us_idle;
-- 
1.4.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] [PKT_SCHED] RED: Fix overflow in calculation of queue average
  2006-08-04 15:44   ` [PATCH v2] " Ilpo Järvinen
@ 2006-08-04 23:36     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2006-08-04 23:36 UTC (permalink / raw)
  To: ilpo.jarvinen; +Cc: shemminger, netdev

From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Fri, 4 Aug 2006 18:44:20 +0300 (EEST)

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-04 23:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2006-08-04 15:44   ` [PATCH v2] " Ilpo Järvinen
2006-08-04 23:36     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).