Skip to content

Commit ade6d4a

Browse files
thuehnjmberg-intel
authored andcommitted
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 <[email protected]> Acked-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 50e55a8 commit ade6d4a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/mac80211/rc80211_minstrel.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
static inline int
2828
minstrel_ewma(int old, int new, int weight)
2929
{
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;
3136
}
3237

3338
struct minstrel_rate_stats {

0 commit comments

Comments
 (0)