Skip to content

Commit 506dbf9

Browse files
nbd168jmberg-intel
authored andcommitted
mac80211: rc80211_minstrel: remove variance / stddev calculation
When there are few packets (e.g. for sampling attempts), the exponentially weighted variance is usually vastly overestimated, making the resulting data essentially useless. As far as I know, there has not been any practical use for this, so let's not waste any cycles on it. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent f4ec7cb commit 506dbf9

File tree

4 files changed

+9
-51
lines changed

4 files changed

+9
-51
lines changed

net/mac80211/rc80211_minstrel.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ minstrel_calc_rate_stats(struct minstrel_rate_stats *mrs)
167167
if (unlikely(!mrs->att_hist)) {
168168
mrs->prob_ewma = cur_prob;
169169
} else {
170-
/* update exponential weighted moving variance */
171-
mrs->prob_ewmv = minstrel_ewmv(mrs->prob_ewmv,
172-
cur_prob,
173-
mrs->prob_ewma,
174-
EWMA_LEVEL);
175-
176170
/*update exponential weighted moving avarage */
177171
mrs->prob_ewma = minstrel_ewma(mrs->prob_ewma,
178172
cur_prob,

net/mac80211/rc80211_minstrel.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,6 @@ minstrel_ewma(int old, int new, int weight)
3535
return old + incr;
3636
}
3737

38-
/*
39-
* Perform EWMV (Exponentially Weighted Moving Variance) calculation
40-
*/
41-
static inline int
42-
minstrel_ewmv(int old_ewmv, int cur_prob, int prob_ewma, int weight)
43-
{
44-
int diff, incr;
45-
46-
diff = cur_prob - prob_ewma;
47-
incr = (EWMA_DIV - weight) * diff / EWMA_DIV;
48-
return weight * (old_ewmv + MINSTREL_TRUNC(diff * incr)) / EWMA_DIV;
49-
}
50-
5138
struct minstrel_rate_stats {
5239
/* current / last sampling period attempts/success counters */
5340
u16 attempts, last_attempts;
@@ -56,11 +43,8 @@ struct minstrel_rate_stats {
5643
/* total attempts/success counters */
5744
u32 att_hist, succ_hist;
5845

59-
/* statistis of packet delivery probability
60-
* prob_ewma - exponential weighted moving average of prob
61-
* prob_ewmsd - exp. weighted moving standard deviation of prob */
46+
/* prob_ewma - exponential weighted moving average of prob */
6247
u16 prob_ewma;
63-
u16 prob_ewmv;
6448

6549
/* maximum retry counts */
6650
u8 retry_count;
@@ -140,14 +124,6 @@ struct minstrel_debugfs_info {
140124
char buf[];
141125
};
142126

143-
/* Get EWMSD (Exponentially Weighted Moving Standard Deviation) * 10 */
144-
static inline int
145-
minstrel_get_ewmsd10(struct minstrel_rate_stats *mrs)
146-
{
147-
unsigned int ewmv = mrs->prob_ewmv;
148-
return int_sqrt(MINSTREL_TRUNC(ewmv * 1000 * 1000));
149-
}
150-
151127
extern const struct rate_control_ops mac80211_minstrel;
152128
void minstrel_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
153129

net/mac80211/rc80211_minstrel_debugfs.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,13 @@ minstrel_stats_open(struct inode *inode, struct file *file)
7070
p = ms->buf;
7171
p += sprintf(p, "\n");
7272
p += sprintf(p,
73-
"best __________rate_________ ________statistics________ ____last_____ ______sum-of________\n");
73+
"best __________rate_________ ____statistics___ ____last_____ ______sum-of________\n");
7474
p += sprintf(p,
75-
"rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n");
75+
"rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n");
7676

7777
for (i = 0; i < mi->n_rates; i++) {
7878
struct minstrel_rate *mr = &mi->r[i];
7979
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
80-
unsigned int prob_ewmsd;
8180

8281
*(p++) = (i == mi->max_tp_rate[0]) ? 'A' : ' ';
8382
*(p++) = (i == mi->max_tp_rate[1]) ? 'B' : ' ';
@@ -93,15 +92,13 @@ minstrel_stats_open(struct inode *inode, struct file *file)
9392
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
9493
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
9594
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
96-
prob_ewmsd = minstrel_get_ewmsd10(mrs);
9795

98-
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
96+
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u"
9997
" %3u %3u %-3u "
10098
"%9llu %-9llu\n",
10199
tp_max / 10, tp_max % 10,
102100
tp_avg / 10, tp_avg % 10,
103101
eprob / 10, eprob % 10,
104-
prob_ewmsd / 10, prob_ewmsd % 10,
105102
mrs->retry_count,
106103
mrs->last_success,
107104
mrs->last_attempts,
@@ -137,7 +134,6 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)
137134
for (i = 0; i < mi->n_rates; i++) {
138135
struct minstrel_rate *mr = &mi->r[i];
139136
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
140-
unsigned int prob_ewmsd;
141137

142138
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[0]) ? "A" : ""));
143139
p += sprintf(p, "%s" ,((i == mi->max_tp_rate[1]) ? "B" : ""));
@@ -153,14 +149,12 @@ minstrel_stats_csv_open(struct inode *inode, struct file *file)
153149
tp_max = minstrel_get_tp_avg(mr, MINSTREL_FRAC(100,100));
154150
tp_avg = minstrel_get_tp_avg(mr, mrs->prob_ewma);
155151
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
156-
prob_ewmsd = minstrel_get_ewmsd10(mrs);
157152

158-
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,%u,"
153+
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,%u,"
159154
"%llu,%llu,%d,%d\n",
160155
tp_max / 10, tp_max % 10,
161156
tp_avg / 10, tp_avg % 10,
162157
eprob / 10, eprob % 10,
163-
prob_ewmsd / 10, prob_ewmsd % 10,
164158
mrs->retry_count,
165159
mrs->last_success,
166160
mrs->last_attempts,

net/mac80211/rc80211_minstrel_ht_debugfs.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
5757
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
5858
static const int bitrates[4] = { 10, 20, 55, 110 };
5959
int idx = i * MCS_GROUP_RATES + j;
60-
unsigned int prob_ewmsd;
6160
unsigned int duration;
6261

6362
if (!(mi->supported[i] & BIT(j)))
@@ -104,15 +103,13 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
104103
tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
105104
tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
106105
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
107-
prob_ewmsd = minstrel_get_ewmsd10(mrs);
108106

109-
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u %3u.%1u"
107+
p += sprintf(p, "%4u.%1u %4u.%1u %3u.%1u"
110108
" %3u %3u %-3u "
111109
"%9llu %-9llu\n",
112110
tp_max / 10, tp_max % 10,
113111
tp_avg / 10, tp_avg % 10,
114112
eprob / 10, eprob % 10,
115-
prob_ewmsd / 10, prob_ewmsd % 10,
116113
mrs->retry_count,
117114
mrs->last_success,
118115
mrs->last_attempts,
@@ -149,9 +146,9 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
149146

150147
p += sprintf(p, "\n");
151148
p += sprintf(p,
152-
" best ____________rate__________ ________statistics________ _____last____ ______sum-of________\n");
149+
" best ____________rate__________ ____statistics___ _____last____ ______sum-of________\n");
153150
p += sprintf(p,
154-
"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)] [retry|suc|att] [#success | #attempts]\n");
151+
"mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]\n");
155152

156153
p = minstrel_ht_stats_dump(mi, MINSTREL_CCK_GROUP, p);
157154
for (i = 0; i < MINSTREL_CCK_GROUP; i++)
@@ -206,7 +203,6 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
206203
struct minstrel_rate_stats *mrs = &mi->groups[i].rates[j];
207204
static const int bitrates[4] = { 10, 20, 55, 110 };
208205
int idx = i * MCS_GROUP_RATES + j;
209-
unsigned int prob_ewmsd;
210206
unsigned int duration;
211207

212208
if (!(mi->supported[i] & BIT(j)))
@@ -251,14 +247,12 @@ minstrel_ht_stats_csv_dump(struct minstrel_ht_sta *mi, int i, char *p)
251247
tp_max = minstrel_ht_get_tp_avg(mi, i, j, MINSTREL_FRAC(100, 100));
252248
tp_avg = minstrel_ht_get_tp_avg(mi, i, j, mrs->prob_ewma);
253249
eprob = MINSTREL_TRUNC(mrs->prob_ewma * 1000);
254-
prob_ewmsd = minstrel_get_ewmsd10(mrs);
255250

256-
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u.%u,%u,%u,"
251+
p += sprintf(p, "%u.%u,%u.%u,%u.%u,%u,%u,"
257252
"%u,%llu,%llu,",
258253
tp_max / 10, tp_max % 10,
259254
tp_avg / 10, tp_avg % 10,
260255
eprob / 10, eprob % 10,
261-
prob_ewmsd / 10, prob_ewmsd % 10,
262256
mrs->retry_count,
263257
mrs->last_success,
264258
mrs->last_attempts,

0 commit comments

Comments
 (0)