Skip to contentSkip to conversation

mac80211/minstrel_ht: increase sampling frequency of some slower rates

PATCH In review Felix Fietkau 3 participants 9 messages Mar 3, 2013 – Mar 5, 2013 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mac80211/minstrel_ht: increase sampling frequency of some slower rates

If a rate is below the max_tp_rate, sample it frequently if:
- it is above max_tp_rate2, or
- it is above max_prob_rate and is a candidate for max_prob_rate (has fewer streams than max_tp_rate).
This helps the retry chain recover more quickly from bad statistics caused by collisions or interference, and slightly reduces throughput fluctuations with higher rates.

---
 net/mac80211/rc80211_minstrel_ht.c | 20 ++++++++++++--------
 net/mac80211/rc80211_minstrel_ht.h |  1 +
 2 files changed, 13 insertions(+), 8 deletions(-)
net/mac80211/rc80211_minstrel_ht.c +12 -8
index 4d35bc5..1b69924 100644
@@ -246,7 +246,6 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	struct minstrel_rate_stats *mr;
 	int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
 	int group, i, index;
-	int prob_max_streams = 1;
 
 	if (mi->ampdu_packets > 0) {
 		mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -330,7 +329,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 			cur_tp2 = cur_tp;
 			mi->max_tp_rate = mg->max_tp_rate;
 			cur_tp = mr->cur_tp;
-			prob_max_streams = minstrel_mcs_groups[group].streams - 1;
+			mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
 		}
 
 		mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
@@ -340,8 +339,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 		}
 	}
 
-	if (prob_max_streams < 1)
-		prob_max_streams = 1;
+	if (mi->max_prob_streams < 1)
+		mi->max_prob_streams = 1;
 
 	for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
 		mg = &mi->groups[group];
@@ -349,7 +348,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 			continue;
 		mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
 		if (cur_prob_tp < mr->cur_tp &&
-		    minstrel_mcs_groups[group].streams <= prob_max_streams) {
+		    minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
 			mi->max_prob_rate = mg->max_prob_rate;
 			cur_prob = mr->cur_prob;
 			cur_prob_tp = mr->cur_tp;
@@ -630,6 +629,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 {
 	struct minstrel_rate_stats *mr;
 	struct minstrel_mcs_group_data *mg;
+	unsigned int sample_dur, sample_group;
 	int sample_idx = 0;
 
 	if (mi->sample_wait > 0) {
@@ -644,7 +644,8 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	mg = &mi->groups[mi->sample_group];
 	sample_idx = sample_table[mg->column][mg->index];
 	mr = &mg->rates[sample_idx];
-	sample_idx += mi->sample_group * MCS_GROUP_RATES;
+	sample_group = mi->sample_group;
+	sample_idx += sample_group * MCS_GROUP_RATES;
 	minstrel_next_sample_idx(mi);
 
 	/*
@@ -665,8 +666,11 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	 * Make sure that lower rates get sampled only occasionally,
 	 * if the link is working perfectly.
 	 */
-	if (minstrel_get_duration(sample_idx) >
-	    minstrel_get_duration(mi->max_tp_rate)) {
+	sample_dur = minstrel_get_duration(sample_idx);
+	if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
+	    (mi->max_prob_streams <
+	     minstrel_mcs_groups[sample_group].streams ||
+	     sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
 		if (mr->sample_skipped < 20)
 			return -1;
 
net/mac80211/rc80211_minstrel_ht.h +1 -0
index 302dbd5..c6d6a0d 100644
@@ -85,6 +85,7 @@ struct minstrel_ht_sta {
 
 	/* best probability rate */
 	unsigned int max_prob_rate;
+	unsigned int max_prob_streams;
 
 	/* time of last status update */
 	unsigned long stats_update;
Signature · 1 line
1.8.0.2
#1 lore raw

PATCH 2/2 mac80211/minstrel_ht: fix spacing between sample attempts

A sample attempt should only count in mi->sample_tries if the sample attempt wasn't skipped based on slower rate criteria.
This patch increases the sampling frequency for potentially desirable rates and thus enables faster recovery from interference or collisions.

---
 net/mac80211/rc80211_minstrel_ht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rc80211_minstrel_ht.c +1 -1
index 1b69924..da4ec73 100644
@@ -640,7 +640,6 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 	if (!mi->sample_tries)
 		return -1;
 
-	mi->sample_tries--;
 	mg = &mi->groups[mi->sample_group];
 	sample_idx = sample_table[mg->column][mg->index];
 	mr = &mg->rates[sample_idx];
@@ -677,6 +676,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
 		if (mi->sample_slow++ > 2)
 			return -1;
 	}
+	mi->sample_tries--;
 
 	return sample_idx;
 }
Signature · 1 line
1.8.0.2
maintainer
#2 lore raw
In reply to Felix Fietkau
Quoted 7 lines · Felix Fietkau

If a rate is below the max_tp_rate, sample it frequently if:
- it is above max_tp_rate2, or
- it is above max_prob_rate and is a candidate for max_prob_rate (has fewer streams than max_tp_rate).
This helps the retry chain recover more quickly from bad statistics caused by collisions or interference, and slightly reduces throughput fluctuations with higher rates.

Applied both.

johannes

#3 lore raw
In reply to Felix Fietkau

On 2013-03-03 12:49 +0100, Felix Fietkau wrote [email protected]:

Hi, in my case this two patches cause throughput drop, withous it i have 50-55Mbs with it applied only 35-40.

FF>If a rate is below the max_tp_rate, sample it frequently if:
FF>- it is above max_tp_rate2, or
FF>- it is above max_prob_rate and is a candidate for max_prob_rate
FF> (has fewer streams than max_tp_rate).
FF>This helps the retry chain recover more quickly from bad statistics
FF>caused by collisions or interference, and slightly reduces throughput FF>fluctuations with higher rates.
FF>
FF>Signed-off-by: Felix Fietkau <[email protected]>
FF>---
FF> net/mac80211/rc80211_minstrel_ht.c | 20 ++++++++++++--------
FF> net/mac80211/rc80211_minstrel_ht.h | 1 +
FF> 2 files changed, 13 insertions(+), 8 deletions(-)
FF>
FF>diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c FF>index 4d35bc5..1b69924 100644
FF>--- a/net/mac80211/rc80211_minstrel_ht.c
FF>+++ b/net/mac80211/rc80211_minstrel_ht.c
FF>@@ -246,7 +246,6 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> struct minstrel_rate_stats *mr;
FF> int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
FF> int group, i, index;
FF>- int prob_max_streams = 1;
FF>
FF> if (mi->ampdu_packets > 0) {
FF> mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
FF>@@ -330,7 +329,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> cur_tp2 = cur_tp;
FF> mi->max_tp_rate = mg->max_tp_rate;
FF> cur_tp = mr->cur_tp;
FF>- prob_max_streams = minstrel_mcs_groups[group].streams - 1;
FF>+ mi->max_prob_streams = minstrel_mcs_groups[group].streams - 1;
FF> }
FF>
FF> mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
FF>@@ -340,8 +339,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> }
FF> }
FF>
FF>- if (prob_max_streams < 1)
FF>- prob_max_streams = 1;
FF>+ if (mi->max_prob_streams < 1)
FF>+ mi->max_prob_streams = 1;
FF>
FF> for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
FF> mg = &mi->groups[group];
FF>@@ -349,7 +348,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> continue;
FF> mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
FF> if (cur_prob_tp < mr->cur_tp &&
FF>- minstrel_mcs_groups[group].streams <= prob_max_streams) {
FF>+ minstrel_mcs_groups[group].streams <= mi->max_prob_streams) {
FF> mi->max_prob_rate = mg->max_prob_rate;
FF> cur_prob = mr->cur_prob;
FF> cur_prob_tp = mr->cur_tp;
FF>@@ -630,6 +629,7 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) FF> {
FF> struct minstrel_rate_stats *mr;
FF> struct minstrel_mcs_group_data *mg;
FF>+ unsigned int sample_dur, sample_group;
FF> int sample_idx = 0;
FF>
FF> if (mi->sample_wait > 0) {
FF>@@ -644,7 +644,8 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> mg = &mi->groups[mi->sample_group];
FF> sample_idx = sample_table[mg->column][mg->index];
FF> mr = &mg->rates[sample_idx];
FF>- sample_idx += mi->sample_group * MCS_GROUP_RATES;
FF>+ sample_group = mi->sample_group;
FF>+ sample_idx += sample_group * MCS_GROUP_RATES;
FF> minstrel_next_sample_idx(mi);
FF>
FF> /*
FF>@@ -665,8 +666,11 @@ minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
FF> * Make sure that lower rates get sampled only occasionally,
FF> * if the link is working perfectly.
FF> */
FF>- if (minstrel_get_duration(sample_idx) >
FF>- minstrel_get_duration(mi->max_tp_rate)) {
FF>+ sample_dur = minstrel_get_duration(sample_idx);
FF>+ if (sample_dur >= minstrel_get_duration(mi->max_tp_rate2) &&
FF>+ (mi->max_prob_streams <
FF>+ minstrel_mcs_groups[sample_group].streams ||
FF>+ sample_dur >= minstrel_get_duration(mi->max_prob_rate))) {
FF> if (mr->sample_skipped < 20)
FF> return -1;
FF>
FF>diff --git a/net/mac80211/rc80211_minstrel_ht.h b/net/mac80211/rc80211_minstrel_ht.h FF>index 302dbd5..c6d6a0d 100644
FF>--- a/net/mac80211/rc80211_minstrel_ht.h
FF>+++ b/net/mac80211/rc80211_minstrel_ht.h
FF>@@ -85,6 +85,7 @@ struct minstrel_ht_sta {
FF>
FF> /* best probability rate */
FF> unsigned int max_prob_rate;
FF>+ unsigned int max_prob_streams;
FF>
FF> /* time of last status update */
FF> unsigned long stats_update;
FF>

C уважением With Best Regards
Георгиевский Юрий. Georgiewskiy Yuriy
+7 4872 711666 +7 4872 711666
факс +7 4872 711143 fax +7 4872 711143
Компания ООО "Ай Ти Сервис" IT Service Ltd

http://nkoort.ru                  http://nkoort.ru
JID: [email protected]            JID: [email protected]
YG129-RIPE                        YG129-RIPE
#4 lore raw
Quoted 4 lines · Georgiewskiy Yuriy

On 2013-03-03 12:49 +0100, Felix Fietkau wrote [email protected]:

Hi, in my case this two patches cause throughput drop, withous it i have 50-55Mbs with it applied only 35-40.

Please show me the rate control statistics from debugfs.

- Felix

#5 lore raw

On 2013-03-05 12:49 +0100, Felix Fietkau wrote Georgiewskiy Yuriy:

FF>On 2013-03-05 11:35 AM, Georgiewskiy Yuriy wrote:
FF>> On 2013-03-03 12:49 +0100, Felix Fietkau wrote [email protected]:
FF>>
FF>> Hi, in my case this two patches cause throughput drop, withous it i have 50-55Mbs FF>> with it applied only 35-40.
FF>Please show me the rate control statistics from debugfs.

in attachment

C уважением With Best Regards
Георгиевский Юрий. Georgiewskiy Yuriy
+7 4872 711666 +7 4872 711666
факс +7 4872 711143 fax +7 4872 711143
Компания ООО "Ай Ти Сервис" IT Service Ltd

http://nkoort.ru                  http://nkoort.ru
JID: [email protected]            JID: [email protected]
YG129-RIPE                        YG129-RIPE
#6 lore raw
Quoted 10 lines · Georgiewskiy Yuriy

On 2013-03-05 12:49 +0100, Felix Fietkau wrote Georgiewskiy Yuriy:

FF>On 2013-03-05 11:35 AM, Georgiewskiy Yuriy wrote:
FF>> On 2013-03-03 12:49 +0100, Felix Fietkau wrote [email protected]:
FF>>
FF>> Hi, in my case this two patches cause throughput drop, withous it i have 50-55Mbs FF>> with it applied only 35-40.
FF>Please show me the rate control statistics from debugfs.

in attachment

Please test if this patch helps:
---

net/mac80211/rc80211_minstrel_ht.c +1 -1
@@ -480,7 +480,7 @@ minstrel_ht_tx_status(void *priv, struct
 
 	if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
 		mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
-		mi->sample_tries = 2;
+		mi->sample_tries = 1;
 		mi->sample_count--;
 	}
 
#7 lore raw

On 2013-03-05 13:26 +0100, Felix Fietkau wrote Georgiewskiy Yuriy:

FF>Please test if this patch helps:
FF>---
FF>--- a/net/mac80211/rc80211_minstrel_ht.c
FF>+++ b/net/mac80211/rc80211_minstrel_ht.c
FF>@@ -480,7 +480,7 @@ minstrel_ht_tx_status(void *priv, struct FF>
FF> if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
FF> mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
FF>- mi->sample_tries = 2;
FF>+ mi->sample_tries = 1;
FF> mi->sample_count--;
FF> }

Seems this helps, with this patch throughput is near as without this two patches applied.

C уважением With Best Regards
Георгиевский Юрий. Georgiewskiy Yuriy
+7 4872 711666 +7 4872 711666
факс +7 4872 711143 fax +7 4872 711143
Компания ООО "Ай Ти Сервис" IT Service Ltd

http://nkoort.ru                  http://nkoort.ru
JID: [email protected]            JID: [email protected]
YG129-RIPE                        YG129-RIPE
#8 lore raw
Quoted 16 lines · Georgiewskiy Yuriy

On 2013-03-05 13:26 +0100, Felix Fietkau wrote Georgiewskiy Yuriy:

FF>Please test if this patch helps:
FF>---
FF>--- a/net/mac80211/rc80211_minstrel_ht.c
FF>+++ b/net/mac80211/rc80211_minstrel_ht.c
FF>@@ -480,7 +480,7 @@ minstrel_ht_tx_status(void *priv, struct FF>
FF> if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
FF> mi->sample_wait = 16 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
FF>- mi->sample_tries = 2;
FF>+ mi->sample_tries = 1;
FF> mi->sample_count--;
FF> }

Quoted 1 line

Seems this helps, with this patch throughput is near as without this two patches applied.

OK, thanks for testing. I will submit it now.

- Felix