From: Eric Dumazet Date: Sat, 12 May 2012 03:32:13 +0000 (+0000) Subject: codel: use Newton method instead of sqrt() and divides X-Git-Tag: v3.5-rc1~109^2~86 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=536edd67109df5e0cdb2c4ee759e9bade7976367;p=pandora-kernel.git 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 Signed-off-by: Eric Dumazet Cc: Dave Taht Cc: Kathleen Nichols Cc: Tom Herbert Cc: Matt Mathis Cc: Yuchung Cheng Cc: Nandita Dukkipati Cc: Stephen Hemminger Signed-off-by: David S. Miller --- Reading git-diff-tree failed