1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 14 Dec 2021 17:53:12 +0100
3 Subject: [PATCH] mac80211: use coarse boottime for airtime fairness code
5 The time values used by the airtime fairness code only need to be accurate
6 enough to cover station activity detection.
7 Using ktime_get_coarse_boottime_ns instead of ktime_get_boottime_ns will
8 drop the accuracy down to jiffies intervals, but at the same time saves
9 a lot of CPU cycles in a hot path
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 --- a/net/mac80211/tx.c
15 +++ b/net/mac80211/tx.c
16 @@ -3827,7 +3827,7 @@ struct ieee80211_txq *ieee80211_next_txq
18 struct ieee80211_local *local = hw_to_local(hw);
19 struct airtime_sched_info *air_sched;
20 - u64 now = ktime_get_boottime_ns();
21 + u64 now = ktime_get_coarse_boottime_ns();
22 struct ieee80211_txq *ret = NULL;
23 struct airtime_info *air_info;
24 struct txq_info *txqi = NULL;
25 @@ -3954,7 +3954,7 @@ void ieee80211_update_airtime_weight(str
29 - now = ktime_get_boottime_ns();
30 + now = ktime_get_coarse_boottime_ns();
32 lockdep_assert_held(&air_sched->lock);
34 @@ -3980,7 +3980,7 @@ void ieee80211_schedule_txq(struct ieee8
35 struct ieee80211_local *local = hw_to_local(hw);
36 struct txq_info *txqi = to_txq_info(txq);
37 struct airtime_sched_info *air_sched;
38 - u64 now = ktime_get_boottime_ns();
39 + u64 now = ktime_get_coarse_boottime_ns();
40 struct airtime_info *air_info;
43 @@ -4038,7 +4038,7 @@ static void __ieee80211_unschedule_txq(s
46 airtime_set_active(air_sched, air_info,
47 - ktime_get_boottime_ns());
48 + ktime_get_coarse_boottime_ns());
50 rb_erase_cached(&txqi->schedule_order,
51 &air_sched->active_txqs);
52 @@ -4126,7 +4126,7 @@ bool ieee80211_txq_may_transmit(struct i
53 if (RB_EMPTY_NODE(&txqi->schedule_order))
56 - now = ktime_get_boottime_ns();
57 + now = ktime_get_coarse_boottime_ns();
59 /* Like in ieee80211_next_txq(), make sure the first station in the
60 * scheduling order is eligible for transmission to avoid starvation.