2fc957570321d40f59e34056a37125da5a4e9d5b
[openwrt/svn-archive/archive.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 --- a/include/net/codel.h
43 +++ b/include/net/codel.h
44 @@ -305,6 +305,8 @@ static struct sk_buff *codel_dequeue(str
45 }
46 }
47 } else if (drop) {
48 + u32 delta;
49 +
50 if (params->ecn && INET_ECN_set_ce(skb)) {
51 stats->ecn_mark++;
52 } else {
53 @@ -320,9 +322,11 @@ static struct sk_buff *codel_dequeue(str
54 * assume that the drop rate that controlled the queue on the
55 * last cycle is a good starting point to control it now.
56 */
57 - if (codel_time_before(now - vars->drop_next,
58 + delta = vars->count - vars->lastcount;
59 + if (delta > 1 &&
60 + codel_time_before(now - vars->drop_next,
61 16 * params->interval)) {
62 - vars->count = (vars->count - vars->lastcount) | 1;
63 + vars->count = delta;
64 /* we dont care if rec_inv_sqrt approximation
65 * is not very precise :
66 * Next Newton steps will correct it quadratically.