lkml.org 
[lkml]   [2012]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sch_red: fix weighted average calculation
Date
This patch fixes an apparent bug in the running weighted average calculation
used in the RED algorithm.

Going by the described formula:
qavg = qavg*(1-W) + backlog*W
=> qavg = qavg + (backlog - qavg) * W

... with W converted to a pre-calculated shift, this then becomes:
qavg = qavg + (backlog - qavg) >> logW

... giving the modified expression introduced by this patch.

Signed-off-by: John Dowdal <jdowdal@ti.com>
---
include/net/red.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/red.h b/include/net/red.h
index ef46058..05960a4 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -287,7 +287,7 @@ static inline unsigned long red_calc_qavg_no_idle_time(const struct red_parms *p
*
* --ANK (980924)
*/
- return v->qavg + (backlog - (v->qavg >> p->Wlog));
+ return v->qavg + (backlog - v->qavg) >> p->Wlog;
}

static inline unsigned long red_calc_qavg(const struct red_parms *p,
--
1.7.9.5


\
 
 \ /
  Last update: 2012-09-13 16:21    [W:0.601 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site