]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mac80211: reduce calculation costs of EWMA
authorThomas Huehn <thomas@net.t-labs.tu-berlin.de>
Tue, 24 Mar 2015 20:09:42 +0000 (21:09 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 1 Apr 2015 18:44:33 +0000 (20:44 +0200)
This patch reduces the calculation costs of the EWMA macro from
"2x multiplication and 1 addition" down to "1x multiplication and
2x additions". This slightly improves performance depending on the
CPU architecture.

Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
Acked-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/rc80211_minstrel.h

index 0083036161afbcfb6230a69701fee5354c8d320c..9c85a610b57b51ae14e3c135b337d48b1d4a65d1 100644 (file)
 static inline int
 minstrel_ewma(int old, int new, int weight)
 {
-       return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV;
+       int diff, incr;
+
+       diff = new - old;
+       incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
+
+       return old + incr;
 }
 
 struct minstrel_rate_stats {