Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: minstrel_ht: reduce the need to sample slower rates

In order to more gracefully be able to fall back to lower rates without too
much throughput fluctuations, initialize all untested rates below tested ones
to the maximum probabilty of higher rates.
Usually this leads to untested lower rates getting initialized with a
probability value of 100%, making them better candidates for fallback without
having to rely on random probing

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://lore.kernel.org/r/20210127055735.78599-3-nbd@nbd.name
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Felix Fietkau and committed by
Johannes Berg
7aece471 2012a2f7

+8 -12
+8 -10
net/mac80211/rc80211_minstrel_ht.c
··· 791 791 unsigned int cur_prob; 792 792 793 793 if (unlikely(mrs->attempts > 0)) { 794 - mrs->sample_skipped = 0; 795 794 cur_prob = MINSTREL_FRAC(mrs->success, mrs->attempts); 796 795 minstrel_filter_avg_add(&mrs->prob_avg, 797 796 &mrs->prob_avg_1, cur_prob); 798 797 mrs->att_hist += mrs->attempts; 799 798 mrs->succ_hist += mrs->success; 800 - } else { 801 - mrs->sample_skipped++; 802 799 } 803 800 804 801 mrs->last_success = mrs->success; ··· 848 851 mi->ampdu_packets = 0; 849 852 } 850 853 851 - mi->sample_slow = 0; 852 854 mi->sample_count = 0; 853 855 854 856 if (mi->supported[MINSTREL_CCK_GROUP]) ··· 878 882 /* Find best rate sets within all MCS groups*/ 879 883 for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) { 880 884 u16 *tp_rate = tmp_mcs_tp_rate; 885 + u16 last_prob = 0; 881 886 882 887 mg = &mi->groups[group]; 883 888 if (!mi->supported[group]) ··· 893 896 if (group == MINSTREL_CCK_GROUP && ht_supported) 894 897 tp_rate = tmp_legacy_tp_rate; 895 898 896 - for (i = 0; i < MCS_GROUP_RATES; i++) { 899 + for (i = MCS_GROUP_RATES - 1; i >= 0; i--) { 897 900 if (!(mi->supported[group] & BIT(i))) 898 901 continue; 899 902 ··· 902 905 mrs = &mg->rates[i]; 903 906 mrs->retry_updated = false; 904 907 minstrel_ht_calc_rate_stats(mp, mrs); 908 + 909 + if (mrs->att_hist) 910 + last_prob = max(last_prob, mrs->prob_avg); 911 + else 912 + mrs->prob_avg = max(last_prob, mrs->prob_avg); 905 913 cur_prob = mrs->prob_avg; 906 914 907 915 if (minstrel_ht_get_tp_avg(mi, group, i, cur_prob) == 0) ··· 1471 1469 if (sample_dur >= minstrel_get_duration(tp_rate2) && 1472 1470 (cur_max_tp_streams - 1 < 1473 1471 minstrel_mcs_groups[sample_group].streams || 1474 - sample_dur >= minstrel_get_duration(mi->max_prob_rate))) { 1475 - if (mrs->sample_skipped < 20) 1472 + sample_dur >= minstrel_get_duration(mi->max_prob_rate))) 1476 1473 return -1; 1477 1474 1478 - if (mi->sample_slow++ > 2) 1479 - return -1; 1480 - } 1481 1475 mi->sample_tries--; 1482 1476 1483 1477 return sample_idx;
-2
net/mac80211/rc80211_minstrel_ht.h
··· 123 123 u8 retry_count; 124 124 u8 retry_count_rtscts; 125 125 126 - u8 sample_skipped; 127 126 bool retry_updated; 128 127 }; 129 128 ··· 178 179 u8 sample_wait; 179 180 u8 sample_tries; 180 181 u8 sample_count; 181 - u8 sample_slow; 182 182 183 183 enum minstrel_sample_mode sample_mode; 184 184 u16 sample_rate;