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

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