[Bloat] [PATCH net-next] sch_red: Adaptative RED AQM

2011-12-08 Thread Eric Dumazet
Adaptative RED AQM for linux, based on paper from Sally FLoyd,
Ramakrishna Gummadi, and Scott Shenker, August 2001 :

http://icir.org/floyd/papers/adaptiveRed.pdf

Goal of Adaptative RED is to make max_p a dynamic value between 1% and
50% to reach the target average queue : (max_th - min_th) / 2


Every 500 ms:
 if (avg  target and max_p = 0.5)
  increase max_p : max_p += alpha;
 else if (avg  target and max_p = 0.01)
  decrease max_p : max_p *= beta;

target :[min_th + 0.4*(min_th - max_th),
  min_th + 0.6*(min_th - max_th)].
alpha : min(0.01, max_p / 4)
beta : 0.9
max_P is a Q0.32 fixed point number (unsigned, with 32 bits mantissa)


Changes against our RED implementation are :

max_p is no longer a negative power of two (1/(2^Plog)), but a Q0.32
fixed point number, to allow full range described in Adatative paper.

To deliver a random number, we now use a reciprocal divide (thats really
a multiply), but this operation is done once per marked/droped packet
when in RED_BETWEEN_TRESH window, so added cost (compared to previous
AND operation) is near zero.

dump operation gives current max_p value in a new TCA_RED_MAX_P
attribute.

Example on a 10Mbit link :

tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 8sec red \
   limit 40 min 3 max 9 avpkt 1000 \
   burst 55 ecn adaptative bandwidth 10Mbit

# tc -s -d qdisc show dev eth3
...
qdisc red 10: parent 1:1 limit 40b min 3b max 9b ecn
adaptative ewma 5 max_p=0.113335 Scell_log 15
 Sent 50414282 bytes 34504 pkt (dropped 35, overlimits 1392 requeues 0) 
 rate 9749Kbit 831pps backlog 72056b 16p requeues 0 
  marked 1357 early 35 pdrop 0 other 0


Signed-off-by: Eric Dumazet eric.duma...@gmail.com
---
 include/linux/pkt_sched.h |6 +-
 include/net/red.h |  101 +---
 lib/reciprocal_div.c  |2 
 net/sched/sch_red.c   |   21 +++
 4 files changed, 111 insertions(+), 19 deletions(-)

diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index fb556dc..e41e0d4 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -181,6 +181,7 @@ enum {
TCA_RED_UNSPEC,
TCA_RED_PARMS,
TCA_RED_STAB,
+   TCA_RED_MAX_P,
__TCA_RED_MAX,
 };
 
@@ -194,8 +195,9 @@ struct tc_red_qopt {
unsigned char   Plog;   /* log(P_max/(qth_max-qth_min)) */
unsigned char   Scell_log;  /* cell size for idle damping */
unsigned char   flags;
-#define TC_RED_ECN 1
-#define TC_RED_HARDDROP2
+#define TC_RED_ECN 1
+#define TC_RED_HARDDROP2
+#define TC_RED_ADAPTATIVE  4
 };
 
 struct tc_red_xstats {
diff --git a/include/net/red.h b/include/net/red.h
index b72a3b8..f4e9533 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -5,6 +5,7 @@
 #include net/pkt_sched.h
 #include net/inet_ecn.h
 #include net/dsfield.h
+#include linux/reciprocal_div.h
 
 /* Random Early Detection (RED) algorithm.
===
@@ -87,6 +88,29 @@
etc.
  */
 
+/*
+ * Adaptative RED : An Algorithm for Increasing the Robustness of RED's AQM
+ * (Sally FLoyd, Ramakrishna Gummadi, and Scott Shenker) August 2001
+ *
+ * Every 500 ms:
+ *  if (avg  target and max_p = 0.5)
+ *   increase max_p : max_p += alpha;
+ *  else if (avg  target and max_p = 0.01)
+ *   decrease max_p : max_p *= beta;
+ *
+ * target :[qth_min + 0.4*(qth_min - qth_max),
+ *  qth_min + 0.6*(qth_min - qth_max)].
+ * alpha : min(0.01, max_p / 4)
+ * beta : 0.9
+ * max_P is a Q0.32 fixed point number (with 32 bits mantissa)
+ * max_P between 0.01 and 0.5 (1% - 50%) [ Its no longer a negative power of 
two ]
+ */
+#define RED_ONE_PERCENT ((u32)DIV_ROUND_CLOSEST(1ULL32, 100))
+
+#define MAX_P_MIN (1 * RED_ONE_PERCENT)
+#define MAX_P_MAX (50 * RED_ONE_PERCENT)
+#define MAX_P_ALPHA(val) min(MAX_P_MIN, val / 4)
+
 #define RED_STAB_SIZE  256
 #define RED_STAB_MASK  (RED_STAB_SIZE - 1)
 
@@ -101,10 +125,14 @@ struct red_stats {
 
 struct red_parms {
/* Parameters */
-   u32 qth_min;/* Min avg length threshold: A scaled */
-   u32 qth_max;/* Max avg length threshold: A scaled */
+   u32 qth_min;/* Min avg length threshold: Wlog 
scaled */
+   u32 qth_max;/* Max avg length threshold: Wlog 
scaled */
u32 Scell_max;
-   u32 Rmask;  /* Cached random mask, see red_rmask */
+   u32 max_P;  /* probability, [0 .. 1.0] 32 scaled */
+   u32 max_P_reciprocal; /* reciprocal_value(max_P / 
qth_delta) */
+   u32 qth_delta;  /* max_th - min_th */
+   u32 target_min; /* min_th + 0.4*(max_th - min_th) */
+   u32 target_max; /* min_th + 0.6*(max_th - min_th) */
u8  Scell_log;
u8  Wlog;   /* log(W)   */
  

Re: [Bloat] [PATCH net-next] sch_red: Adaptative RED AQM

2011-12-08 Thread Stephen Hemminger
On Thu, 08 Dec 2011 17:06:03 +0100
Eric Dumazet eric.duma...@gmail.com wrote:

 Changes against our RED implementation are :
 
 max_p is no longer a negative power of two (1/(2^Plog)), but a Q0.32
 fixed point number, to allow full range described in Adatative paper.
 
 To deliver a random number, we now use a reciprocal divide (thats really
 a multiply), but this operation is done once per marked/droped packet
 when in RED_BETWEEN_TRESH window, so added cost (compared to previous
 AND operation) is near zero.
 
 dump operation gives current max_p value in a new TCA_RED_MAX_P
 attribute.
 
 Example on a 10Mbit link :
 
 tc qdisc add dev $DEV parent 1:1 handle 10: est 1sec 8sec red \
limit 40 min 3 max 9 avpkt 1000 \
burst 55 ecn adaptative bandwidth 10Mbit
 
 # tc -s -d qdisc show dev eth3
 ...
 qdisc red 10: parent 1:1 limit 40b min 3b max 9b ecn
 adaptative ewma 5 max_p=0.113335 Scell_log 15
  Sent 50414282 bytes 34504 pkt (dropped 35, overlimits 1392 requeues 0) 
  rate 9749Kbit 831pps backlog 72056b 16p requeues 0 
   marked 1357 early 35 pdrop 0 other 0
 
 
 Signed-off-by: Eric Dumazet eric.duma...@gmail.com

Is this backward compatible for users that don't specify
an adaptive parameter.
___
Bloat mailing list
Bloat@lists.bufferbloat.net
https://lists.bufferbloat.net/listinfo/bloat


Re: [Bloat] [PATCH net-next] sch_red: Adaptative RED AQM

2011-12-08 Thread David Miller
From: Eric Dumazet eric.duma...@gmail.com
Date: Thu, 08 Dec 2011 17:06:03 +0100

 Adaptative RED AQM for linux, based on paper from Sally FLoyd,
 Ramakrishna Gummadi, and Scott Shenker, August 2001 :

Applied.
___
Bloat mailing list
Bloat@lists.bufferbloat.net
https://lists.bufferbloat.net/listinfo/bloat