From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Cc: toke@kernel.org, johannes@sipsolutions.net
Subject: [PATCH 4/7] mac80211: keep recently active tx queues in scheduling list
Date: Sat, 25 Jun 2022 23:24:08 +0200 [thread overview]
Message-ID: <20220625212411.36675-4-nbd@nbd.name> (raw)
In-Reply-To: <20220625212411.36675-1-nbd@nbd.name>
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 <nbd@nbd.name>
---
net/mac80211/ieee80211_i.h | 7 +++++++
net/mac80211/sta_info.h | 1 +
net/mac80211/tx.c | 40 ++++++++++++++++++++++++++++++++++----
3 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8ef27e0f9371..c5a76bec03a4 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -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;
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 785fefe8c41a..aa599f82b065 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -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;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 0509486ac40a..71c1d2a5eef3 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -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]);
--
2.36.1
next prev parent reply other threads:[~2022-06-25 21:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-25 21:24 [PATCH 1/7] mac80211: switch airtime fairness back to deficit round-robin scheduling Felix Fietkau
2022-06-25 21:24 ` [PATCH 2/7] mac80211: make sta airtime deficit field s32 instead of s64 Felix Fietkau
2022-06-27 15:02 ` Toke Høiland-Jørgensen
2022-06-25 21:24 ` [PATCH 3/7] mac80211: consider aql_tx_pending when checking airtime deficit Felix Fietkau
2022-06-27 15:02 ` Toke Høiland-Jørgensen
2022-06-25 21:24 ` Felix Fietkau [this message]
2022-06-27 15:03 ` [PATCH 4/7] mac80211: keep recently active tx queues in scheduling list Toke Høiland-Jørgensen
2022-06-25 21:24 ` [PATCH 5/7] mac80211: add a per-PHY AQL limit to improve fairness Felix Fietkau
2022-06-27 15:04 ` Toke Høiland-Jørgensen
2022-06-25 21:24 ` [PATCH 6/7] mac80211: add debugfs file to display per-phy AQL pending airtime Felix Fietkau
2022-06-27 15:04 ` Toke Høiland-Jørgensen
2022-06-25 21:24 ` [PATCH 7/7] mac80211: only accumulate airtime deficit for active clients Felix Fietkau
2022-06-27 15:04 ` Toke Høiland-Jørgensen
2022-06-27 15:02 ` [PATCH 1/7] mac80211: switch airtime fairness back to deficit round-robin scheduling Toke Høiland-Jørgensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220625212411.36675-4-nbd@nbd.name \
--to=nbd@nbd.name \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=toke@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).