diff options
author | Thomas Huehn <thomas@net.t-labs.tu-berlin.de> | 2015-03-24 16:09:42 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2015-04-01 14:44:33 -0400 |
commit | ade6d4a2ec57d258bc181a155288c267dd8cf094 (patch) | |
tree | 60df72e1b0f08c2f544a5ae4cfcec181f5ae0de1 /net/mac80211 | |
parent | 50e55a8ea76fb593403cc09767b6371c17364ba8 (diff) |
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>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/rc80211_minstrel.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h index 0083036161af..9c85a610b57b 100644 --- a/net/mac80211/rc80211_minstrel.h +++ b/net/mac80211/rc80211_minstrel.h | |||
@@ -27,7 +27,12 @@ | |||
27 | static inline int | 27 | static inline int |
28 | minstrel_ewma(int old, int new, int weight) | 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 | struct minstrel_rate_stats { | 38 | struct minstrel_rate_stats { |