c43cd3acb9f15501175d6b3ae43efef7aa28c982
[openwrt/staging/nbd.git] /
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
4
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
10
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 ---
13
14 --- a/net/mac80211/tx.c
15 +++ b/net/mac80211/tx.c
16 @@ -3820,7 +3820,7 @@ struct ieee80211_txq *ieee80211_next_txq
17 {
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 @@ -3947,7 +3947,7 @@ void ieee80211_update_airtime_weight(str
26 u64 weight_sum = 0;
27
28 if (unlikely(!now))
29 - now = ktime_get_boottime_ns();
30 + now = ktime_get_coarse_boottime_ns();
31
32 lockdep_assert_held(&air_sched->lock);
33
34 @@ -3973,7 +3973,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;
41 u8 ac = txq->ac;
42 bool was_active;
43 @@ -4031,7 +4031,7 @@ static void __ieee80211_unschedule_txq(s
44
45 if (!purge)
46 airtime_set_active(air_sched, air_info,
47 - ktime_get_boottime_ns());
48 + ktime_get_coarse_boottime_ns());
49
50 rb_erase_cached(&txqi->schedule_order,
51 &air_sched->active_txqs);
52 @@ -4119,7 +4119,7 @@ bool ieee80211_txq_may_transmit(struct i
53 if (RB_EMPTY_NODE(&txqi->schedule_order))
54 goto out;
55
56 - now = ktime_get_boottime_ns();
57 + now = ktime_get_coarse_boottime_ns();
58
59 /* Like in ieee80211_next_txq(), make sure the first station in the
60 * scheduling order is eligible for transmission to avoid starvation.