332-mac80211-consider-aql_tx_pending-when-checking-airti.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From: Felix Fietkau <[email protected]>
  2. Date: Mon, 20 Jun 2022 14:59:09 +0200
  3. Subject: [PATCH] mac80211: consider aql_tx_pending when checking airtime
  4. deficit
  5. When queueing packets for a station, deficit only gets added once the packets
  6. have been transmitted, which could be much later. During that time, a lot of
  7. temporary unfairness could happen, which could lead to bursty behavior.
  8. Fix this by subtracting the aql_tx_pending when checking the deficit in tx
  9. scheduling.
  10. Signed-off-by: Felix Fietkau <[email protected]>
  11. ---
  12. --- a/net/mac80211/tx.c
  13. +++ b/net/mac80211/tx.c
  14. @@ -3818,6 +3818,13 @@ out:
  15. }
  16. EXPORT_SYMBOL(ieee80211_tx_dequeue);
  17. +static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac)
  18. +{
  19. + struct airtime_info *air_info = &sta->airtime[ac];
  20. +
  21. + return air_info->deficit - atomic_read(&air_info->aql_tx_pending);
  22. +}
  23. +
  24. struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)
  25. {
  26. struct ieee80211_local *local = hw_to_local(hw);
  27. @@ -3848,7 +3855,7 @@ struct ieee80211_txq *ieee80211_next_txq
  28. struct sta_info *sta = container_of(txqi->txq.sta,
  29. struct sta_info, sta);
  30. bool aql_check = ieee80211_txq_airtime_check(hw, &txqi->txq);
  31. - s32 deficit = sta->airtime[txqi->txq.ac].deficit;
  32. + s32 deficit = ieee80211_sta_deficit(sta, txqi->txq.ac);
  33. if (aql_check)
  34. found_eligible_txq = true;
  35. @@ -3973,7 +3980,7 @@ bool ieee80211_txq_may_transmit(struct i
  36. continue;
  37. }
  38. sta = container_of(iter->txq.sta, struct sta_info, sta);
  39. - if (sta->airtime[ac].deficit < 0)
  40. + if (ieee80211_sta_deficit(sta, ac) < 0)
  41. sta->airtime[ac].deficit += sta->airtime_weight;
  42. list_move_tail(&iter->schedule_order, &local->active_txqs[ac]);
  43. }