[bufferbloat] Codel: avoid a nul rec_inv_sqrt
[openwrt.git] / target / linux / generic / patches-3.3 / 049-codel-refine-one-condition-to-avoid-a-nul-rec_inv_sqrt.patch
1 From patchwork Mon Jul 30 06:52:21 2012
2 Content-Type: text/plain; charset="utf-8"
3 MIME-Version: 1.0
4 Content-Transfer-Encoding: 7bit
5 Subject: codel: refine one condition to avoid a nul rec_inv_sqrt
6 Date: Sun, 29 Jul 2012 20:52:21 -0000
7 From: Eric Dumazet <eric.dumazet@gmail.com>
8 X-Patchwork-Id: 173968
9 Message-Id: <1343631141.2626.13293.camel@edumazet-glaptop>
10 To: David Miller <davem@davemloft.net>
11 Cc: netdev <netdev@vger.kernel.org>, Anton Mich <lp2s1h@gmail.com>
12
13 From: Eric Dumazet <edumazet@google.com>
14
15 One condition before codel_Newton_step() was not good if
16 we never left the dropping state for a flow. As a result
17 rec_inv_sqrt was 0, instead of the ~0 initial value.
18
19 codel control law was then set to a very aggressive mode, dropping
20 many packets before reaching 'target' and recovering from this problem.
21
22 To keep codel_vars_init() as efficient as possible, refine
23 the condition to make sure rec_inv_sqrt initial value is correct
24
25 Many thanks to Anton Mich for discovering the issue and suggesting
26 a fix.
27
28 Reported-by: Anton Mich <lp2s1h@gmail.com>
29 Signed-off-by: Eric Dumazet <edumazet@google.com>
30
31 ---
32 include/net/codel.h |    8 ++++++--
33  1 file changed, 6 insertions(+), 2 deletions(-)
34
35
36
37 --
38 To unsubscribe from this list: send the line "unsubscribe netdev" in
39 the body of a message to majordomo@vger.kernel.org
40 More majordomo info at  http://vger.kernel.org/majordomo-info.html
41
42 diff --git a/include/net/codel.h b/include/net/codel.h
43 index 550debf..389cf62 100644
44 --- a/include/net/codel.h
45 +++ b/include/net/codel.h
46 @@ -305,6 +305,8 @@ static struct sk_buff *codel_dequeue(struct Qdisc *sch,
47                         }
48                 }
49         } else if (drop) {
50 +               u32 delta;
51 +
52                 if (params->ecn && INET_ECN_set_ce(skb)) {
53                         stats->ecn_mark++;
54                 } else {
55 @@ -320,9 +322,11 @@ static struct sk_buff *codel_dequeue(struct Qdisc *sch,
56                  * assume that the drop rate that controlled the queue on the
57                  * last cycle is a good starting point to control it now.
58                  */
59 -               if (codel_time_before(now - vars->drop_next,
60 +               delta = vars->count - vars->lastcount;
61 +               if (delta > 1 &&
62 +                   codel_time_before(now - vars->drop_next,
63                                       16 * params->interval)) {
64 -                       vars->count = (vars->count - vars->lastcount) | 1;
65 +                       vars->count = delta;
66                         /* we dont care if rec_inv_sqrt approximation
67                          * is not very precise :
68                          * Next Newton steps will correct it quadratically.