diff mbox

[1/2] mac80211: minstrels: spare numerous useless calls to get_random_bytes

Message ID 1383928473-798-1-git-send-email-karl.beldan@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Karl Beldan Nov. 8, 2013, 4:34 p.m. UTC
From: Karl Beldan <karl.beldan@rivierawaves.com>

These are called to init the sample tables.
This occurs once in minstrel_ht upon its registration (since it uses one
single common sample table for all STAs), and once per sta addition in
minstrel.

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
---
 net/mac80211/rc80211_minstrel.c    | 3 +--
 net/mac80211/rc80211_minstrel_ht.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Felix Fietkau Nov. 8, 2013, 4:39 p.m. UTC | #1
On 2013-11-08 17:34, Karl Beldan wrote:
> From: Karl Beldan <karl.beldan@rivierawaves.com>
> 
> These are called to init the sample tables.
> This occurs once in minstrel_ht upon its registration (since it uses one
> single common sample table for all STAs), and once per sta addition in
> minstrel.
> 
> Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Acked-by: Felix Fietkau <nbd@openwrt.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Nov. 11, 2013, 3:45 p.m. UTC | #2
On Fri, 2013-11-08 at 17:34 +0100, Karl Beldan wrote:
> From: Karl Beldan <karl.beldan@rivierawaves.com>
> 
> These are called to init the sample tables.
> This occurs once in minstrel_ht upon its registration (since it uses one
> single common sample table for all STAs), and once per sta addition in
> minstrel.

This commit log is suboptimal, it doesn't even seem to describe a change
but rather the behaviour after (or before?) the change?

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Karl Beldan Nov. 11, 2013, 7:43 p.m. UTC | #3
On Mon, Nov 11, 2013 at 04:45:45PM +0100, Johannes Berg wrote:
> On Fri, 2013-11-08 at 17:34 +0100, Karl Beldan wrote:
> > From: Karl Beldan <karl.beldan@rivierawaves.com>
> > 
> > These are called to init the sample tables.
> > This occurs once in minstrel_ht upon its registration (since it uses one
> > single common sample table for all STAs), and once per sta addition in
> > minstrel.
> 
> This commit log is suboptimal, it doesn't even seem to describe a change
> but rather the behaviour after (or before?) the change?
> 
Other than replacing:
"These are called to init the sample tables.\nThis occurs once in"
with:
"These are called to init the sample tables, which occurs once in",
plus this ridiculously small diff in a non convoluted localized code
path .. 

FYI, this lowers the prng bytes demands from about 10*12*8bytes to
10*8bytes per non-ht sta addition and at minstrel_ht init. This is to
relate to the email posted just after I posted this change:
http://marc.info/?l=linux-wireless&m=138393239432434&w=2
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 7fa1b36..a40e4e3 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -422,10 +422,9 @@  init_sample_table(struct minstrel_sta_info *mi)
 	memset(mi->sample_table, 0xff, SAMPLE_COLUMNS * mi->n_rates);
 
 	for (col = 0; col < SAMPLE_COLUMNS; col++) {
+		get_random_bytes(rnd, sizeof(rnd));
 		for (i = 0; i < mi->n_rates; i++) {
-			get_random_bytes(rnd, sizeof(rnd));
 			new_idx = (i + rnd[i & 7]) % mi->n_rates;
-
 			while (SAMPLE_TBL(mi, new_idx, col) != 0xff)
 				new_idx = (new_idx + 1) % mi->n_rates;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 5d60779..aeec401 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -1052,10 +1052,9 @@  init_sample_table(void)
 
 	memset(sample_table, 0xff, sizeof(sample_table));
 	for (col = 0; col < SAMPLE_COLUMNS; col++) {
+		get_random_bytes(rnd, sizeof(rnd));
 		for (i = 0; i < MCS_GROUP_RATES; i++) {
-			get_random_bytes(rnd, sizeof(rnd));
 			new_idx = (i + rnd[i]) % MCS_GROUP_RATES;
-
 			while (sample_table[col][new_idx] != 0xff)
 				new_idx = (new_idx + 1) % MCS_GROUP_RATES;