306-mac80211-use-coarse-boottime-for-airtime-fairness-co.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From: Felix Fietkau <[email protected]>
  2. Date: Tue, 14 Dec 2021 17:53:12 +0100
  3. Subject: [PATCH] mac80211: use coarse boottime for airtime fairness code
  4. The time values used by the airtime fairness code only need to be accurate
  5. enough to cover station activity detection.
  6. Using ktime_get_coarse_boottime_ns instead of ktime_get_boottime_ns will
  7. drop the accuracy down to jiffies intervals, but at the same time saves
  8. a lot of CPU cycles in a hot path
  9. Signed-off-by: Felix Fietkau <[email protected]>
  10. ---
  11. --- a/net/mac80211/tx.c
  12. +++ b/net/mac80211/tx.c
  13. @@ -3821,7 +3821,7 @@ struct ieee80211_txq *ieee80211_next_txq
  14. {
  15. struct ieee80211_local *local = hw_to_local(hw);
  16. struct airtime_sched_info *air_sched;
  17. - u64 now = ktime_get_boottime_ns();
  18. + u64 now = ktime_get_coarse_boottime_ns();
  19. struct ieee80211_txq *ret = NULL;
  20. struct airtime_info *air_info;
  21. struct txq_info *txqi = NULL;
  22. @@ -3948,7 +3948,7 @@ void ieee80211_update_airtime_weight(str
  23. u64 weight_sum = 0;
  24. if (unlikely(!now))
  25. - now = ktime_get_boottime_ns();
  26. + now = ktime_get_coarse_boottime_ns();
  27. lockdep_assert_held(&air_sched->lock);
  28. @@ -3974,7 +3974,7 @@ void ieee80211_schedule_txq(struct ieee8
  29. struct ieee80211_local *local = hw_to_local(hw);
  30. struct txq_info *txqi = to_txq_info(txq);
  31. struct airtime_sched_info *air_sched;
  32. - u64 now = ktime_get_boottime_ns();
  33. + u64 now = ktime_get_coarse_boottime_ns();
  34. struct airtime_info *air_info;
  35. u8 ac = txq->ac;
  36. bool was_active;
  37. @@ -4032,7 +4032,7 @@ static void __ieee80211_unschedule_txq(s
  38. if (!purge)
  39. airtime_set_active(air_sched, air_info,
  40. - ktime_get_boottime_ns());
  41. + ktime_get_coarse_boottime_ns());
  42. rb_erase_cached(&txqi->schedule_order,
  43. &air_sched->active_txqs);
  44. @@ -4120,7 +4120,7 @@ bool ieee80211_txq_may_transmit(struct i
  45. if (RB_EMPTY_NODE(&txqi->schedule_order))
  46. goto out;
  47. - now = ktime_get_boottime_ns();
  48. + now = ktime_get_coarse_boottime_ns();
  49. /* Like in ieee80211_next_txq(), make sure the first station in the
  50. * scheduling order is eligible for transmission to avoid starvation.