Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: reduce calculation costs of EWMA

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>

authored by

Thomas Huehn and committed by
Johannes Berg
ade6d4a2 50e55a8e

+6 -1
+6 -1
net/mac80211/rc80211_minstrel.h
··· 27 27 static inline int 28 28 minstrel_ewma(int old, int new, int weight) 29 29 { 30 - return (new * (EWMA_DIV - weight) + old * weight) / EWMA_DIV; 30 + int diff, incr; 31 + 32 + diff = new - old; 33 + incr = (EWMA_DIV - weight) * diff / EWMA_DIV; 34 + 35 + return old + incr; 31 36 } 32 37 33 38 struct minstrel_rate_stats {