Eric Dumazet 536edd6710 codel: use Newton method instead of sqrt() and divides
As Van pointed out, interval/sqrt(count) can be implemented using
multiplies only.

http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots

This patch implements the Newton method and reciprocal divide.

Total cost is 15 cycles instead of 120 on my Corei5 machine (64bit
kernel).

There is a small 'error' for count values < 5, but we don't really care.

I reuse a hole in struct codel_vars :
 - pack the dropping boolean into one bit
 - use 31bit to store the reciprocal value of sqrt(count).

Suggested-by: Van Jacobson <van@pollere.net>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dave Taht <dave.taht@bufferbloat.net>
Cc: Kathleen Nichols <nichols@pollere.com>
Cc: Tom Herbert <therbert@google.com>
Cc: Matt Mathis <mattmathis@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Nandita Dukkipati <nanditad@google.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-05-12 15:50:49 -04:00
..
2011-03-31 11:26:23 -03:00
2012-04-15 12:44:40 -04:00
2012-04-15 12:44:40 -04:00
2012-04-15 12:44:40 -04:00
2010-10-27 11:37:32 -07:00
2011-03-31 11:26:23 -03:00
2012-04-15 12:44:40 -04:00
2011-07-26 16:49:47 -07:00
2012-03-08 00:30:32 -08:00
2012-04-17 22:31:59 -04:00
2010-10-25 13:09:45 -07:00
2012-04-15 12:44:40 -04:00
2012-05-08 19:40:33 +02:00
2012-04-14 14:47:05 -04:00
2011-03-31 11:26:23 -03:00
2011-09-16 19:20:20 -04:00
2011-07-26 16:49:47 -07:00
2011-05-17 14:16:58 -04:00
2011-12-11 18:25:16 -05:00
2012-04-15 12:44:40 -04:00
2012-05-10 23:24:35 -04:00
2012-04-15 12:44:40 -04:00
2012-04-15 12:44:40 -04:00
2012-04-02 04:33:45 -04:00