049-codel-refine-one-condition-to-avoid-a-nul-rec_inv_sqrt.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From b8fc328668a74e1314a19266755a54abd875e5a6 Mon Sep 17 00:00:00 2001
  2. From: Eric Dumazet <[email protected]>
  3. Date: Sun, 29 Jul 2012 20:52:21 +0000
  4. Subject: [PATCH] codel: refine one condition to avoid a nul rec_inv_sqrt
  5. commit 2359a47671fc4fb0fe5e9945f76c2cb10792c0f8 upstream.
  6. One condition before codel_Newton_step() was not good if
  7. we never left the dropping state for a flow. As a result
  8. rec_inv_sqrt was 0, instead of the ~0 initial value.
  9. codel control law was then set to a very aggressive mode, dropping
  10. many packets before reaching 'target' and recovering from this problem.
  11. To keep codel_vars_init() as efficient as possible, refine
  12. the condition to make sure rec_inv_sqrt initial value is correct
  13. Many thanks to Anton Mich for discovering the issue and suggesting
  14. a fix.
  15. Reported-by: Anton Mich <[email protected]>
  16. Signed-off-by: Eric Dumazet <[email protected]>
  17. Signed-off-by: David S. Miller <[email protected]>
  18. ---
  19. include/net/codel.h | 8 ++++++--
  20. 1 file changed, 6 insertions(+), 2 deletions(-)
  21. --- a/include/net/codel.h
  22. +++ b/include/net/codel.h
  23. @@ -305,6 +305,8 @@ static struct sk_buff *codel_dequeue(str
  24. }
  25. }
  26. } else if (drop) {
  27. + u32 delta;
  28. +
  29. if (params->ecn && INET_ECN_set_ce(skb)) {
  30. stats->ecn_mark++;
  31. } else {
  32. @@ -320,9 +322,11 @@ static struct sk_buff *codel_dequeue(str
  33. * assume that the drop rate that controlled the queue on the
  34. * last cycle is a good starting point to control it now.
  35. */
  36. - if (codel_time_before(now - vars->drop_next,
  37. + delta = vars->count - vars->lastcount;
  38. + if (delta > 1 &&
  39. + codel_time_before(now - vars->drop_next,
  40. 16 * params->interval)) {
  41. - vars->count = (vars->count - vars->lastcount) | 1;
  42. + vars->count = delta;
  43. /* we dont care if rec_inv_sqrt approximation
  44. * is not very precise :
  45. * Next Newton steps will correct it quadratically.