All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, nbd@nbd.name, thomas@net.t-labs.tu-berlin.de
Subject: [PATCH v3 09/10] mac80211: reduce calculation costs of EWMA
Date: Tue, 17 Mar 2015 18:29:18 +0100	[thread overview]
Message-ID: <1426613359-31306-9-git-send-email-thomas@net.t-labs.tu-berlin.de> (raw)
In-Reply-To: <1426613359-31306-1-git-send-email-thomas@net.t-labs.tu-berlin.de>

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>
---
 net/mac80211/rc80211_minstrel.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/rc80211_minstrel.h b/net/mac80211/rc80211_minstrel.h
index 6693d8d..38158b0 100644
--- a/net/mac80211/rc80211_minstrel.h
+++ b/net/mac80211/rc80211_minstrel.h
@@ -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 {
-- 
2.3.0


  parent reply	other threads:[~2015-03-17 17:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-17 17:29 [PATCH v3 01/10] mac80211: enhance readability of Minstrels rc_stats output Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 02/10] mac80211: enhance readability of Minstrel-HTs " Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 03/10] mac80211: add new Minstrel statistic output via csv Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 04/10] mac80211: add new Minstrel-HT " Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 05/10] mac80211: unify Minstrel & Minstrel-HTs calculation of rate statistics Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 06/10] mac80211: improve Minstrel variable & function naming Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 07/10] mac80211: restructure per-rate throughput calculation into function Thomas Huehn
2015-03-17 17:29 ` [PATCH v3 08/10] mac80211: add max. lossless throughput per rate to rc_stats Thomas Huehn
2015-03-21 23:20   ` Felix Fietkau
2015-03-17 17:29 ` Thomas Huehn [this message]
2015-03-17 17:29 ` [PATCH v3 10/10] mac80211: add standard deviation to Minstrels throughput statistic Thomas Huehn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426613359-31306-9-git-send-email-thomas@net.t-labs.tu-berlin.de \
    --to=thomas@net.t-labs.tu-berlin.de \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.