mac80211: switch airtime fairness back to deficit round-robin scheduling
PATCH 1/7 mac80211: switch airtime fairness back to deficit round-robin scheduling
This reverts commits 6a789ba679d652587532cec2a0e0274fda172f3b and 2433647bc8d983a543e7d31b41ca2de1c7e2c198.
The virtual time scheduler code has a number of issues:
- queues slowed down by hardware/firmware powersave handling were not properly handled.
- on ath10k in push-pull mode, tx queues that the driver tries to pull from were starved, causing excessive latency
- delay between tx enqueue and reported airtime use were causing excessively bursty tx behavior
The bursty behavior may also be present on the round-robin scheduler, but there it is much easier to fix without introducing additional regressions
--- include/net/mac80211.h | 17 +- net/mac80211/cfg.c | 35 +--- net/mac80211/debugfs.c | 70 ++----- net/mac80211/debugfs_netdev.c | 32 +-- net/mac80211/debugfs_sta.c | 24 +-- net/mac80211/ieee80211_i.h | 182 ++--------------- net/mac80211/iface.c | 4 - net/mac80211/main.c | 11 +- net/mac80211/rx.c | 6 +- net/mac80211/sta_info.c | 67 ++----- net/mac80211/sta_info.h | 11 +- net/mac80211/status.c | 19 -- net/mac80211/tx.c | 366 ++++++++++------------------------ 13 files changed, 193 insertions(+), 651 deletions(-)
include/net/mac80211.h +14 -3
@@ -6832,6 +6832,9 @@ static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac) { } +void __ieee80211_schedule_txq (struct ieee80211_hw *hw, +struct ieee80211_txq *txq,bool force); +/** * ieee80211_schedule_txq - schedule a TXQ for transmission *
@@ -6844,7 +6847,11 @@ static inline void ieee80211_txq_schedule_end(struct ieee80211_hw *hw, u8 ac)* The driver may call this function if it has buffered packets for * this TXQ internally. */ -void ieee80211_schedule_txq (struct ieee80211_hw *hw,struct ieee80211_txq *txq); +static inline void +ieee80211_schedule_txq (struct ieee80211_hw *hw,struct ieee80211_txq *txq) +{ +__ieee80211_schedule_txq (hw, txq, true); +}/** * ieee80211_return_txq - return a TXQ previously acquired by ieee80211_next_txq()
@@ -6856,8 +6863,12 @@ void ieee80211_schedule_txq(struct ieee80211_hw *hw, struct ieee80211_txq *txq);* The driver may set force=true if it has buffered packets for this TXQ * internally. */ -void ieee80211_return_txq (struct ieee80211_hw *hw,struct ieee80211_txq *txq, -bool force); +static inline void +ieee80211_return_txq (struct ieee80211_hw *hw,struct ieee80211_txq *txq, +bool force) +{ +__ieee80211_schedule_txq (hw, txq, force); +}/** * ieee80211_txq_may_transmit - check whether TXQ is allowed to transmit
net/mac80211/cfg.c +1 -34
@@ -1581,38 +1581,6 @@ static void sta_apply_mesh_params(struct ieee80211_local *local,#endif } -static void sta_apply_airtime_params (struct ieee80211_local *local, -struct sta_info *sta, -struct station_parameters *params) -{ -u8 ac; - -for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { -struct airtime_sched_info *air_sched = &local->airtime[ac]; -struct airtime_info *air_info = &sta->airtime[ac]; -struct txq_info *txqi; -u8 tid; - -spin_lock_bh (&air_sched->lock); -for (tid =0 ; tid <IEEE80211_NUM_TIDS +1 ; tid++) { -if (air_info->weight == params->airtime_weight || - !sta->sta.txq[tid] || - ac !=ieee80211_ac_from_tid (tid)) -continue ; - -airtime_weight_set (air_info, params->airtime_weight); - - txqi =to_txq_info (sta->sta.txq[tid]); -if (RB_EMPTY_NODE (&txqi->schedule_order)) -continue ; - -ieee80211_update_airtime_weight (local, air_sched, -0 , true); - } -spin_unlock_bh (&air_sched->lock); - } -} -static int sta_apply_parameters (struct ieee80211_local *local,struct sta_info *sta,struct station_parameters *params)
@@ -1811,8 +1779,7 @@ static int sta_apply_parameters(struct ieee80211_local *local,sta_apply_mesh_params (local, sta, params);if (params->airtime_weight) -sta_apply_airtime_params (local, sta, params); - + sta->airtime_weight = params->airtime_weight;/* set the STA state after all sta info from usermode has been set */ if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) ||
net/mac80211/debugfs.c +13 -57
95 lines not on this page · raw message
net/mac80211/debugfs_netdev.c +1 -31
@@ -510,34 +510,6 @@ static ssize_t ieee80211_if_fmt_aqm( }IEEE80211_IF_FILE_R (aqm); -static ssize_t ieee80211_if_fmt_airtime ( -const struct ieee80211_sub_if_data *sdata,char *buf,int buflen) -{ -struct ieee80211_local *local = sdata->local; -struct ieee80211_txq *txq = sdata->vif.txq; -struct airtime_info *air_info; -int len; - -if (!txq) -return 0 ; - -spin_lock_bh (&local->airtime[txq->ac].lock); - air_info =to_airtime_info (txq); - len =scnprintf (buf, - buflen, -"RX: %llu us\nTX: %llu us\nWeight: %u\n" -"Virt-T: %lld us\n" , - air_info->rx_airtime, - air_info->tx_airtime, - air_info->weight, - air_info->v_t); -spin_unlock_bh (&local->airtime[txq->ac].lock); - -return len; -} - -IEEE80211_IF_FILE_R (airtime); -IEEE80211_IF_FILE (multicast_to_unicast, u.ap.multicast_to_unicast,HEX );/* IBSS attributes */
@@ -683,10 +655,8 @@ static void add_common_files(struct ieee80211_sub_if_data *sdata)if (sdata->local->ops->wake_tx_queue && sdata->vif.type !=NL80211_IFTYPE_P2P_DEVICE && - sdata->vif.type !=NL80211_IFTYPE_NAN ) { + sdata->vif.type !=NL80211_IFTYPE_NAN )DEBUGFS_ADD (aqm); -DEBUGFS_ADD (airtime); - } }static void add_sta_files (struct ieee80211_sub_if_data *sdata)
net/mac80211/debugfs_sta.c +12 -12
@@ -202,7 +202,7 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,size_t bufsz =400 ;char *buf =kzalloc (bufsz,GFP_KERNEL ), *p = buf;u64 rx_airtime =0 , tx_airtime =0 ; -u64 v_t[IEEE80211_NUM_ACS ]; +s64 deficit[IEEE80211_NUM_ACS ];ssize_t rv;int ac;
@@ -210,18 +210,18 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,return -ENOMEM ;for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { -spin_lock_bh (&local->airtime[ac].lock); +spin_lock_bh (&local->active_txq_lock[ac]); rx_airtime += sta->airtime[ac].rx_airtime; tx_airtime += sta->airtime[ac].tx_airtime; - v_t[ac] = sta->airtime[ac].v_t; -spin_unlock_bh (&local->airtime[ac].lock); + deficit[ac] = sta->airtime[ac].deficit; +spin_unlock_bh (&local->active_txq_lock[ac]); } p +=scnprintf (p, bufsz + buf - p,"RX: %llu us\nTX: %llu us\nWeight: %u\n" -"Virt-T: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n" , - rx_airtime, tx_airtime, sta->airtime[0 ].weight, - v_t[0 ], v_t[1 ], v_t[2 ], v_t[3 ]); +"Deficit: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n" , + rx_airtime, tx_airtime, sta->airtime_weight, + deficit[0 ], deficit[1 ], deficit[2 ], deficit[3 ]); rv =simple_read_from_buffer (userbuf, count, ppos, buf, p - buf);kfree (buf);
@@ -236,11 +236,11 @@ static ssize_t sta_airtime_write(struct file *file, const char __user *userbuf,int ac;for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { -spin_lock_bh (&local->airtime[ac].lock); +spin_lock_bh (&local->active_txq_lock[ac]); sta->airtime[ac].rx_airtime =0 ; sta->airtime[ac].tx_airtime =0 ; - sta->airtime[ac].v_t =0 ; -spin_unlock_bh (&local->airtime[ac].lock); + sta->airtime[ac].deficit = sta->airtime_weight; +spin_unlock_bh (&local->active_txq_lock[ac]); }return count;
@@ -263,10 +263,10 @@ static ssize_t sta_aql_read(struct file *file, char __user *userbuf,return -ENOMEM ;for (ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) { -spin_lock_bh (&local->airtime[ac].lock); +spin_lock_bh (&local->active_txq_lock[ac]); q_limit_l[ac] = sta->airtime[ac].aql_limit_low; q_limit_h[ac] = sta->airtime[ac].aql_limit_high; -spin_unlock_bh (&local->airtime[ac].lock); +spin_unlock_bh (&local->active_txq_lock[ac]); q_depth[ac] =atomic_read (&sta->airtime[ac].aql_tx_pending); }
net/mac80211/ieee80211_i.h +15 -167
228 lines not on this page · raw message
net/mac80211/iface.c +0 -4
@@ -2176,10 +2176,6 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, } } -for (i =0 ; i <IEEE80211_NUM_ACS ; i++) -init_airtime_info (&sdata->deflink.airtime[i], - &local->airtime[i]); -ieee80211_set_default_queues (sdata); sdata->deflink.ap_power_level =IEEE80211_UNSET_POWER_LEVEL ;
net/mac80211/main.c +4 -7
@@ -784,13 +784,10 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,spin_lock_init (&local->queue_stop_reason_lock);for (i =0 ; i <IEEE80211_NUM_ACS ; i++) { -struct airtime_sched_info *air_sched = &local->airtime[i]; - - air_sched->active_txqs =RB_ROOT_CACHED ; -INIT_LIST_HEAD (&air_sched->active_list); -spin_lock_init (&air_sched->lock); - air_sched->aql_txq_limit_low =IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L ; - air_sched->aql_txq_limit_high = +INIT_LIST_HEAD (&local->active_txqs[i]); +spin_lock_init (&local->active_txq_lock[i]); + local->aql_txq_limit_low[i] =IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L ; + local->aql_txq_limit_high[i] =IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H ; }
net/mac80211/rx.c +5 -1
@@ -1565,8 +1565,12 @@ static void sta_ps_start(struct sta_info *sta)for (tid =0 ; tid <IEEE80211_NUM_TIDS ; tid++) {struct ieee80211_txq *txq = sta->sta.txq[tid]; +struct txq_info *txqi =to_txq_info (txq); -ieee80211_unschedule_txq (&local->hw, txq, false); +spin_lock (&local->active_txq_lock[txq->ac]); +if (!list_empty (&txqi->schedule_order)) +list_del_init (&txqi->schedule_order); +spin_unlock (&local->active_txq_lock[txq->ac]);if (txq_has_queue (txq))set_bit (tid, &sta->txq_buffered_tids);
net/mac80211/sta_info.c +18 -49
95 lines not on this page · raw message
net/mac80211/sta_info.h +3 -8
@@ -135,25 +135,18 @@ enum ieee80211_agg_stop_reason {#define AIRTIME_USE_TX BIT(0)#define AIRTIME_USE_RX BIT(1) -struct airtime_info {u64 rx_airtime;u64 tx_airtime; -u64 v_t; -u64 last_scheduled; -struct list_head list; +s64 deficit;atomic_t aql_tx_pending;/* Estimated airtime for frames pending */ u32 aql_limit_low;u32 aql_limit_high; -u32 weight_reciprocal; -u16 weight; };void ieee80211_sta_update_pending_airtime (struct ieee80211_local *local,struct sta_info *sta,u8 ac,u16 tx_airtime,bool tx_completed); -void ieee80211_register_airtime (struct ieee80211_txq *txq, -u32 tx_airtime,u32 rx_airtime);struct sta_info ;
@@ -607,6 +600,7 @@ struct link_sta_info {* @tid_seq: per-TID sequence numbers for sending to this STA * @airtime: per-AC struct airtime_info describing airtime statistics for this * station +* @airtime_weight: station weight for airtime fairness calculation purposes * @ampdu_mlme: A-MPDU state machine state * @mesh: mesh STA information * @debugfs_dir: debug filesystem directory dentry
@@ -691,6 +685,7 @@ struct sta_info {u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK +1 ];struct airtime_info airtime[IEEE80211_NUM_ACS ]; +u16 airtime_weight;/* * Aggregation information, locked with lock.
net/mac80211/status.c +0 -19
@@ -998,25 +998,6 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,if (!(info->flags &IEEE80211_TX_CTL_INJECTED ) && acked)ieee80211_frame_acked (sta, skb); - }else if (wiphy_ext_feature_isset (local->hw.wiphy, -NL80211_EXT_FEATURE_AIRTIME_FAIRNESS )) { -struct ieee80211_sub_if_data *sdata; -struct ieee80211_txq *txq; -u32 airtime; - -/* Account airtime to multicast queue */ - sdata =ieee80211_sdata_from_skb (local, skb); - -if (sdata && (txq = sdata->vif.txq)) { - airtime = info->status.tx_time ?: -ieee80211_calc_expected_tx_airtime (hw, - &sdata->vif, -NULL , - skb->len, - false); - -ieee80211_register_airtime (txq, airtime,0 ); - } }/* SNMP counters
net/mac80211/tx.c +107 -259
458 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH 2/7 mac80211: make sta airtime deficit field s32 instead of s64
32 bit is more than enough range for the airtime deficit
--- net/mac80211/debugfs_sta.c | 4 ++-- net/mac80211/sta_info.h | 2 +- net/mac80211/tx.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
net/mac80211/debugfs_sta.c +2 -2
@@ -202,7 +202,7 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf,size_t bufsz =400 ;char *buf =kzalloc (bufsz,GFP_KERNEL ), *p = buf;u64 rx_airtime =0 , tx_airtime =0 ; -s64 deficit[IEEE80211_NUM_ACS ]; +s32 deficit[IEEE80211_NUM_ACS ];ssize_t rv;int ac;
@@ -219,7 +219,7 @@ static ssize_t sta_airtime_read(struct file *file, char __user *userbuf, p +=scnprintf (p, bufsz + buf - p,"RX: %llu us\nTX: %llu us\nWeight: %u\n" -"Deficit: VO: %lld us VI: %lld us BE: %lld us BK: %lld us\n" , +"Deficit: VO: %d us VI: %d us BE: %d us BK: %d us\n" , rx_airtime, tx_airtime, sta->airtime_weight, deficit[0 ], deficit[1 ], deficit[2 ], deficit[3 ]);
net/mac80211/sta_info.h +1 -1
@@ -138,7 +138,7 @@ enum ieee80211_agg_stop_reason {struct airtime_info {u64 rx_airtime;u64 tx_airtime; -s64 deficit; +s32 deficit;atomic_t aql_tx_pending;/* Estimated airtime for frames pending */ u32 aql_limit_low;u32 aql_limit_high;
net/mac80211/tx.c +1 -1
@@ -3830,7 +3830,7 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)struct sta_info *sta =container_of (txqi->txq.sta, struct sta_info, sta);bool aql_check =ieee80211_txq_airtime_check (hw, &txqi->txq); -s64 deficit = sta->airtime[txqi->txq.ac].deficit; +s32 deficit = sta->airtime[txqi->txq.ac].deficit;if (aql_check) found_eligible_txq = true;
Signature · 1 line
2.36.1
Re: [PATCH 2/7] mac80211: make sta airtime deficit field s32 instead of s64
Quoted 3 lines · Felix Fietkau
32 bit is more than enough range for the airtime deficit
Signed-off-by Felix Fietkau <[email protected]>
PATCH 3/7 mac80211: consider aql_tx_pending when checking airtime deficit
In reply to Felix FietkauWhen queueing packets for a station, deficit only gets added once the packets have been transmitted, which could be much later. During that time, a lot of temporary unfairness could happen, which could lead to bursty behavior. Fix this by subtracting the aql_tx_pending when checking the deficit in tx scheduling.
--- net/mac80211/tx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/mac80211/tx.c +9 -2
@@ -3800,6 +3800,13 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, }EXPORT_SYMBOL (ieee80211_tx_dequeue); +static inline s32 ieee80211_sta_deficit (struct sta_info *sta,u8 ac) +{ +struct airtime_info *air_info = &sta->airtime[ac]; + +return air_info->deficit -atomic_read (&air_info->aql_tx_pending); +} +struct ieee80211_txq *ieee80211_next_txq (struct ieee80211_hw *hw,u8 ac) {struct ieee80211_local *local =hw_to_local (hw);
@@ -3830,7 +3837,7 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)struct sta_info *sta =container_of (txqi->txq.sta, struct sta_info, sta);bool aql_check =ieee80211_txq_airtime_check (hw, &txqi->txq); -s32 deficit = sta->airtime[txqi->txq.ac].deficit; +s32 deficit =ieee80211_sta_deficit (sta, txqi->txq.ac);if (aql_check) found_eligible_txq = true;
@@ -3955,7 +3962,7 @@ bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,continue ; } sta = container_of(iter->txq.sta, struct sta_info, sta); -if (sta->airtime[ac].deficit <0 ) +if (ieee80211_sta_deficit (sta, ac) <0 ) sta->airtime[ac].deficit += sta->airtime_weight;list_move_tail (&iter->schedule_order, &local->active_txqs[ac]); }
Signature · 1 line
2.36.1
Re: [PATCH 3/7] mac80211: consider aql_tx_pending when checking airtime deficit
Quoted 7 lines · Felix Fietkau
When queueing packets for a station, deficit only gets added once the packets have been transmitted, which could be much later. During that time, a lot of temporary unfairness could happen, which could lead to bursty behavior. Fix this by subtracting the
aql_tx_pendingwhen checking the deficit in tx scheduling.Signed-off-by Felix Fietkau <[email protected]>
PATCH 4/7 mac80211: keep recently active tx queues in scheduling list
In reply to Felix FietkauThis allows proper deficit accounting to ensure that they don't carry their deficit until the next time they become active
--- net/mac80211/ieee80211_i.h | 7 +++++++ net/mac80211/sta_info.h | 1 + net/mac80211/tx.c | 40 ++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-)
net/mac80211/ieee80211_i.h +7 -0
@@ -83,6 +83,13 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];#define IEEE80211_MAX_NAN_INSTANCE_ID 255 + +/* +* Keep a station's queues on the active list for deficit accounting purposes +* if it was active or queued during the last 100ms +*/ +#define AIRTIME_ACTIVE_DURATION (HZ / 10) +struct ieee80211_bss {u32 device_ts_beacon, device_ts_presp;
net/mac80211/sta_info.h +1 -0
@@ -138,6 +138,7 @@ enum ieee80211_agg_stop_reason {struct airtime_info {u64 rx_airtime;u64 tx_airtime; +u32 last_active;s32 deficit;atomic_t aql_tx_pending;/* Estimated airtime for frames pending */ u32 aql_limit_low;
net/mac80211/tx.c +36 -4
@@ -3807,6 +3807,36 @@ static inline s32 ieee80211_sta_deficit(struct sta_info *sta, u8 ac)return air_info->deficit -atomic_read (&air_info->aql_tx_pending); } +static void +ieee80211_txq_set_active (struct txq_info *txqi) +{ +struct sta_info *sta; + +if (!txqi->txq.sta) +return ; + + sta = container_of(txqi->txq.sta, struct sta_info, sta); + sta->airtime[txqi->txq.ac].last_active = (u32 )jiffies; +} + +static bool +ieee80211_txq_keep_active (struct txq_info *txqi) +{ +struct sta_info *sta; +u32 diff; + +if (!txqi->txq.sta) +return false; + + sta = container_of(txqi->txq.sta, struct sta_info, sta); +if (ieee80211_sta_deficit (sta, txqi->txq.ac) >=0 ) +return false; + + diff = (u32 )jiffies - sta->airtime[txqi->txq.ac].last_active; + +return diff <=AIRTIME_ACTIVE_DURATION ; +} +struct ieee80211_txq *ieee80211_next_txq (struct ieee80211_hw *hw,u8 ac) {struct ieee80211_local *local =hw_to_local (hw);
@@ -3853,7 +3883,6 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac) } } -if (txqi->schedule_round == local->schedule_round[ac]) goto out;
@@ -3873,12 +3902,13 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw, {struct ieee80211_local *local =hw_to_local (hw);struct txq_info *txqi =to_txq_info (txq); +bool has_queue;spin_lock_bh (&local->active_txq_lock[txq->ac]); + has_queue = force ||txq_has_queue (txq);if (list_empty (&txqi->schedule_order) && - (force || !skb_queue_empty (&txqi->frags) || - txqi->tin.backlog_packets)) { + (has_queue ||ieee80211_txq_keep_active (txqi))) {/* If airtime accounting is active, always enqueue STAs at the * head of the list to ensure that they only get moved to the * back by the airtime DRR scheduler once they have a negative
@@ -3886,7 +3916,7 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw,* get immediately moved to the back of the list on the next * call to ieee80211_next_txq(). */ -if (txqi->txq.sta && local->airtime_flags && +if (txqi->txq.sta && local->airtime_flags && has_queue &&wiphy_ext_feature_isset (local->hw.wiphy,NL80211_EXT_FEATURE_AIRTIME_FAIRNESS )) list_add(&txqi->schedule_order,
@@ -3894,6 +3924,8 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw,else list_add_tail (&txqi->schedule_order, &local->active_txqs[txq->ac]); +if (has_queue) +ieee80211_txq_set_active (txqi); }spin_unlock_bh (&local->active_txq_lock[txq->ac]);
Signature · 1 line
2.36.1
Re: [PATCH 4/7] mac80211: keep recently active tx queues in scheduling list
Quoted 4 lines · Felix Fietkau
This allows proper deficit accounting to ensure that they don't carry their deficit until the next time they become active
Signed-off-by Felix Fietkau <[email protected]>
PATCH 5/7 mac80211: add a per-PHY AQL limit to improve fairness
In reply to Felix FietkauIn order to maintain fairness, the amount of queueing needs to be limited beyond the simple per-station AQL budget, otherwise the driver can simply repeatedly do scheduling rounds until all queues that have not used their AQL budget become eligble.
To be conservative, use the high AQL limit for the first txq and add half of the low AQL for each subsequent queue.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/main.c | 1 + net/mac80211/sta_info.c | 10 +++++++--- net/mac80211/tx.c | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -1239,6 +1239,7 @@ struct ieee80211_local {u32 aql_txq_limit_high[IEEE80211_NUM_ACS ];u32 aql_threshold;atomic_t aql_total_pending_airtime; +atomic_t aql_ac_pending_airtime[IEEE80211_NUM_ACS ];const struct ieee80211_ops *ops;
net/mac80211/main.c +1 -0
@@ -789,6 +789,7 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len, local->aql_txq_limit_low[i] =IEEE80211_DEFAULT_AQL_TXQ_LIMIT_L ; local->aql_txq_limit_high[i] =IEEE80211_DEFAULT_AQL_TXQ_LIMIT_H ; +atomic_set (&local->aql_ac_pending_airtime[i],0 ); } local->airtime_flags =AIRTIME_USE_TX |AIRTIME_USE_RX ;
net/mac80211/sta_info.c +7 -3
@@ -2075,6 +2075,7 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, &sta->airtime[ac].aql_tx_pending);atomic_add (tx_airtime, &local->aql_total_pending_airtime); +atomic_add (tx_airtime, &local->aql_ac_pending_airtime[ac]);return ; }
@@ -2086,14 +2087,17 @@ void ieee80211_sta_update_pending_airtime(struct ieee80211_local *local, tx_pending, 0); } +atomic_sub (tx_airtime, &local->aql_total_pending_airtime); tx_pending =atomic_sub_return (tx_airtime, - &local->aql_total_pending_airtime); + &local->aql_ac_pending_airtime[ac]);if (WARN_ONCE (tx_pending <0 ,"Device %s AC %d pending airtime underflow: %u, %u" ,wiphy_name (local->hw.wiphy), ac, tx_pending, - tx_airtime)) -atomic_cmpxchg (&local->aql_total_pending_airtime, + tx_airtime)) { +atomic_cmpxchg (&local->aql_ac_pending_airtime[ac], tx_pending,0 ); +atomic_sub (tx_pending, &local->aql_total_pending_airtime); + } } int sta_info_move_state(struct sta_info *sta,
net/mac80211/tx.c +34 -1
@@ -3846,6 +3846,9 @@ struct ieee80211_txq *ieee80211_next_txq(struct ieee80211_hw *hw, u8 ac)spin_lock_bh (&local->active_txq_lock[ac]); +if (!local->schedule_round[ac]) + goto out; + begin: txqi = list_first_entry_or_null(&local->active_txqs[ac], struct txq_info,
@@ -3967,6 +3970,25 @@ bool ieee80211_txq_airtime_check(struct ieee80211_hw *hw, }EXPORT_SYMBOL (ieee80211_txq_airtime_check); +static bool +ieee80211_txq_schedule_airtime_check (struct ieee80211_local *local,u8 ac) +{ +unsigned int num_txq =0 ; +struct txq_info *txq; +u32 aql_limit; + +if (!wiphy_ext_feature_isset (local->hw.wiphy,NL80211_EXT_FEATURE_AQL )) +return true; + +list_for_each_entry (txq, &local->active_txqs[ac], schedule_order) + num_txq++; + + aql_limit = (num_txq -1 ) * local->aql_txq_limit_low[ac] /2 + + local->aql_txq_limit_high[ac]; + +return atomic_read (&local->aql_ac_pending_airtime[ac]) < aql_limit; +} +bool ieee80211_txq_may_transmit (struct ieee80211_hw *hw,struct ieee80211_txq *txq) {
@@ -3983,6 +4005,9 @@ bool ieee80211_txq_may_transmit(struct ieee80211_hw *hw,if (list_empty (&txqi->schedule_order)) goto out; +if (!ieee80211_txq_schedule_airtime_check (local, ac)) + goto out; +list_for_each_entry_safe (iter, tmp, &local->active_txqs[ac], schedule_order) {if (iter == txqi)
@@ -4022,7 +4047,15 @@ void ieee80211_txq_schedule_start(struct ieee80211_hw *hw, u8 ac)struct ieee80211_local *local =hw_to_local (hw);spin_lock_bh (&local->active_txq_lock[ac]); - local->schedule_round[ac]++; + +if (ieee80211_txq_schedule_airtime_check (local, ac)) { + local->schedule_round[ac]++; +if (!local->schedule_round[ac]) + local->schedule_round[ac]++; + }else { + local->schedule_round[ac] =0 ; + } +spin_unlock_bh (&local->active_txq_lock[ac]); }EXPORT_SYMBOL (ieee80211_txq_schedule_start);
Signature · 1 line
2.36.1
Re: [PATCH 5/7] mac80211: add a per-PHY AQL limit to improve fairness
Quoted 9 lines · Felix Fietkau
In order to maintain fairness, the amount of queueing needs to be limited beyond the simple per-station AQL budget, otherwise the driver can simply repeatedly do scheduling rounds until all queues that have not used their AQL budget become eligble.
To be conservative, use the high AQL limit for the first txq and add half of the low AQL for each subsequent queue.
Signed-off-by Felix Fietkau <[email protected]>
PATCH 6/7 mac80211: add debugfs file to display per-phy AQL pending airtime
In reply to Felix FietkauNow that the global pending airtime is more relevant for airtime fairness, it makes sense to make it accessible via debugfs for debugging
--- net/mac80211/debugfs.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
net/mac80211/debugfs.c +31 -0
@@ -201,6 +201,36 @@ static const struct file_operations airtime_flags_ops = { .llseek = default_llseek, }; +static ssize_t aql_pending_read (struct file *file, +char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct ieee80211_local *local = file->private_data; +char buf[400 ]; +int len =0 ; + + len =scnprintf (buf,sizeof (buf), +"AC AQL pending\n" +"VO %u us\n" +"VI %u us\n" +"BE %u us\n" +"BK %u us\n" +"total %u us\n" , +atomic_read (&local->aql_ac_pending_airtime[IEEE80211_AC_VO ]), +atomic_read (&local->aql_ac_pending_airtime[IEEE80211_AC_VI ]), +atomic_read (&local->aql_ac_pending_airtime[IEEE80211_AC_BE ]), +atomic_read (&local->aql_ac_pending_airtime[IEEE80211_AC_BK ]), +atomic_read (&local->aql_total_pending_airtime)); +return simple_read_from_buffer (user_buf, count, ppos, + buf, len); +} + +static const struct file_operations aql_pending_ops = { + .read = aql_pending_read, + .open = simple_open, + .llseek = default_llseek, +}; + static ssize_t aql_txq_limit_read(struct file *file, char __user *user_buf, size_t count,
@@ -631,6 +661,7 @@ void debugfs_hw_add(struct ieee80211_local *local)DEBUGFS_ADD (hw_conf);DEBUGFS_ADD_MODE (force_tx_status,0600 );DEBUGFS_ADD_MODE (aql_enable,0600 ); +DEBUGFS_ADD (aql_pending);if (local->ops->wake_tx_queue)DEBUGFS_ADD_MODE (aqm,0600 );
Signature · 1 line
2.36.1
Re: [PATCH 6/7] mac80211: add debugfs file to display per-phy AQL pending airtime
Quoted 4 lines · Felix Fietkau
Now that the global pending airtime is more relevant for airtime fairness, it makes sense to make it accessible via debugfs for debugging
Signed-off-by Felix Fietkau <[email protected]>
PATCH 7/7 mac80211: only accumulate airtime deficit for active clients
In reply to Felix FietkauWhen a client does not generate any local tx activity, accumulating airtime deficit for the round-robin scheduler can be harmful. If this goes on for too long, the deficit could grow quite large, which might cause unreasonable initial latency once the client becomes active
--- net/mac80211/sta_info.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/mac80211/sta_info.c +6 -1
@@ -2046,6 +2046,7 @@ void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,struct ieee80211_local *local = sta->sdata->local;u8 ac =ieee80211_ac_from_tid (tid);u32 airtime =0 ; +u32 diff;if (sta->local->airtime_flags &AIRTIME_USE_TX ) airtime += tx_airtime;
@@ -2055,7 +2056,11 @@ void ieee80211_sta_register_airtime(struct ieee80211_sta *pubsta, u8 tid,spin_lock_bh (&local->active_txq_lock[ac]); sta->airtime[ac].tx_airtime += tx_airtime; sta->airtime[ac].rx_airtime += rx_airtime; - sta->airtime[ac].deficit -= airtime; + + diff = (u32 )jiffies - sta->airtime[ac].last_active; +if (diff <=AIRTIME_ACTIVE_DURATION ) + sta->airtime[ac].deficit -= airtime; +spin_unlock_bh (&local->active_txq_lock[ac]); }EXPORT_SYMBOL (ieee80211_sta_register_airtime);
Signature · 1 line
2.36.1
Re: [PATCH 7/7] mac80211: only accumulate airtime deficit for active clients
Quoted 6 lines · Felix Fietkau
When a client does not generate any local tx activity, accumulating airtime deficit for the round-robin scheduler can be harmful. If this goes on for too long, the deficit could grow quite large, which might cause unreasonable initial latency once the client becomes active
Signed-off-by Felix Fietkau <[email protected]>
Quoted 11 lines · Felix Fietkau
This reverts commits
6a789ba679d652587532cec2a0e0274fda172f3band2433647bc8d983a543e7d31b41ca2de1c7e2c198.The virtual time scheduler code has a number of issues:
- queues slowed down by hardware/firmware powersave handling were not properly handled.
- on ath10k in push-pull mode, tx queues that the driver tries to pull from were starved, causing excessive latency
- delay between tx enqueue and reported airtime use were causing excessively bursty tx behavior
Quoted 4 lines
The bursty behavior may also be present on the round-robin scheduler, but there it is much easier to fix without introducing additional regressions
Signed-off-by Felix Fietkau <[email protected]>