aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_red.c
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2011-12-08 01:06:03 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-08 19:52:43 -0500
commit8af2a218de38f51ea4b4fa48cac1273319ae260c (patch)
tree07a4557322b79878096172355fb02ab2bae3f432 /net/sched/sch_red.c
parent57459185a19b0246866479522b77cbb9732201d1 (diff)
sch_red: Adaptative RED AQM
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 400000 min 30000 max 90000 avpkt 1000 \ burst 55 ecn adaptative bandwidth 10Mbit # tc -s -d qdisc show dev eth3 ... qdisc red 10: parent 1:1 limit 400000b min 30000b max 90000b 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.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_red.c')
-rw-r--r--net/sched/sch_red.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index d617161f8dd3..8f5a85bf9d10 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -39,6 +39,7 @@
39struct red_sched_data { 39struct red_sched_data {
40 u32 limit; /* HARD maximal queue length */ 40 u32 limit; /* HARD maximal queue length */
41 unsigned char flags; 41 unsigned char flags;
42 struct timer_list adapt_timer;
42 struct red_parms parms; 43 struct red_parms parms;
43 struct red_stats stats; 44 struct red_stats stats;
44 struct Qdisc *qdisc; 45 struct Qdisc *qdisc;
@@ -161,6 +162,8 @@ static void red_reset(struct Qdisc *sch)
161static void red_destroy(struct Qdisc *sch) 162static void red_destroy(struct Qdisc *sch)
162{ 163{
163 struct red_sched_data *q = qdisc_priv(sch); 164 struct red_sched_data *q = qdisc_priv(sch);
165
166 del_timer_sync(&q->adapt_timer);
164 qdisc_destroy(q->qdisc); 167 qdisc_destroy(q->qdisc);
165} 168}
166 169
@@ -209,6 +212,10 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
209 ctl->Plog, ctl->Scell_log, 212 ctl->Plog, ctl->Scell_log,
210 nla_data(tb[TCA_RED_STAB])); 213 nla_data(tb[TCA_RED_STAB]));
211 214
215 del_timer(&q->adapt_timer);
216 if (ctl->flags & TC_RED_ADAPTATIVE)
217 mod_timer(&q->adapt_timer, jiffies + HZ/2);
218
212 if (!q->qdisc->q.qlen) 219 if (!q->qdisc->q.qlen)
213 red_start_of_idle_period(&q->parms); 220 red_start_of_idle_period(&q->parms);
214 221
@@ -216,11 +223,24 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
216 return 0; 223 return 0;
217} 224}
218 225
226static inline void red_adaptative_timer(unsigned long arg)
227{
228 struct Qdisc *sch = (struct Qdisc *)arg;
229 struct red_sched_data *q = qdisc_priv(sch);
230 spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch));
231
232 spin_lock(root_lock);
233 red_adaptative_algo(&q->parms);
234 mod_timer(&q->adapt_timer, jiffies + HZ/2);
235 spin_unlock(root_lock);
236}
237
219static int red_init(struct Qdisc *sch, struct nlattr *opt) 238static int red_init(struct Qdisc *sch, struct nlattr *opt)
220{ 239{
221 struct red_sched_data *q = qdisc_priv(sch); 240 struct red_sched_data *q = qdisc_priv(sch);
222 241
223 q->qdisc = &noop_qdisc; 242 q->qdisc = &noop_qdisc;
243 setup_timer(&q->adapt_timer, red_adaptative_timer, (unsigned long)sch);
224 return red_change(sch, opt); 244 return red_change(sch, opt);
225} 245}
226 246
@@ -243,6 +263,7 @@ static int red_dump(struct Qdisc *sch, struct sk_buff *skb)
243 if (opts == NULL) 263 if (opts == NULL)
244 goto nla_put_failure; 264 goto nla_put_failure;
245 NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt); 265 NLA_PUT(skb, TCA_RED_PARMS, sizeof(opt), &opt);
266 NLA_PUT_U32(skb, TCA_RED_MAX_P, q->parms.max_P);
246 return nla_nest_end(skb, opts); 267 return nla_nest_end(skb, opts);
247 268
248nla_put_failure: 269nla_put_failure: