Skip to content

Commit

Permalink
mac80211: reduce calculation costs of EWMA
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Thomas Huehn authored and Johannes Berg committed Apr 1, 2015
1 parent 50e55a8 commit ade6d4a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/mac80211/rc80211_minstrel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@
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 {
Expand Down

0 comments on commit ade6d4a

Please sign in to comment.