mac80211: Limit TID buffering during BA session setup/teardown
PATCH 1/1 mac80211: Limit TID buffering during BA session setup/teardown
While setting up or tearing down a BA session mac80211 is buffering pending frames for the according TID. However, there's currently no limit on how many frames are buffered possibly leading to an out-of- memory situation. This can happen on systems with little memory when the CPU is fully loaded since the BA session work is executed in process context while frames can still come via softirq.
Apply a limitation to the TIDs pending queue to avoid consuming too much memory in this situation.
--- net/mac80211/tx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
net/mac80211/tx.c +6 -0
@@ -1060,6 +1060,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, {bool queued = false;bool reset_agg_timer = false; +struct sk_buff *purge_skb =NULL ;if (test_bit (HT_AGG_STATE_OPERATIONAL , &tid_tx->state)) { info->flags |=IEEE80211_TX_CTL_AMPDU ;
@@ -1101,8 +1102,13 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, info->control.vif = &tx->sdata->vif; info->flags |=IEEE80211_TX_INTFL_NEED_TXPROCESSING ;__skb_queue_tail (&tid_tx->pending, skb); +if (skb_queue_len (&tid_tx->pending) >STA_MAX_TX_BUFFER ) + purge_skb =__skb_dequeue (&tid_tx->pending); }spin_unlock (&tx->sta->lock); + +if (purge_skb) +dev_kfree_skb (purge_skb); }/* reset session timer */
Signature · 1 line
1.7.7
Johannes Berg
maintainerQuoted 28 lines · Helmut Schaa
While setting up or tearing down a BA session mac80211 is buffering pending frames for the according TID. However, there's currently no limit on how many frames are buffered possibly leading to an out-of- memory situation. This can happen on systems with little memory when the CPU is fully loaded since the BA session work is executed in process context while frames can still come via softirq.
Apply a limitation to the TIDs pending queue to avoid consuming too much memory in this situation.
Signed-off-by Helmut Schaa <[email protected]>--- net/mac80211/tx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)net/mac80211/tx.c +1
-0@@ -1060,6 +1060,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, {bool queued = false;bool reset_agg_timer = false; +struct sk_buff *purge_skb =NULL ;if (test_bit (HT_AGG_STATE_OPERATIONAL , &tid_tx->state)) { info->flags |=IEEE80211_TX_CTL_AMPDU ;
net/mac80211/tx.c static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, · line 1111
Quoted 10 lines
net/mac80211/tx.c +5
-0@@ -1101,8 +1102,13 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, info->control.vif = &tx->sdata->vif; info->flags |=IEEE80211_TX_INTFL_NEED_TXPROCESSING ;__skb_queue_tail (&tid_tx->pending, skb); +if (skb_queue_len (&tid_tx->pending) >STA_MAX_TX_BUFFER ) + purge_skb =__skb_dequeue (&tid_tx->pending); }spin_unlock (&tx->sta->lock); + +if (purge_skb) +dev_kfree_skb (purge_skb);
Shouldn't we stop the netdev queues or something instead?
johannes
Quoted 26 lines · Johannes Berg
Quoted 25 lines · Helmut Schaa
While setting up or tearing down a BA session mac80211 is buffering pending frames for the according TID. However, there's currently no limit on how many frames are buffered possibly leading to an out-of- memory situation. This can happen on systems with little memory when the CPU is fully loaded since the BA session work is executed in process context while frames can still come via softirq.
Apply a limitation to the TIDs pending queue to avoid consuming too much memory in this situation.
Signed-off-by Helmut Schaa <[email protected]>---
net/mac80211/tx.c | 6 ++++++1 files changed, 6 insertions(+), 0 deletions(-)net/mac80211/tx.c +1
-0@@ -1060,6 +1060,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, { bool queued = false; bool reset_agg_timer = false; + struct sk_buff *purge_skb = NULL;
Quoted 15 lines
net/mac80211/tx.c static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, · line 1111
Quoted 13 lines
net/mac80211/tx.c +5
-0if (test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) { info->flags |= IEEE80211_TX_CTL_AMPDU;@@ -1101,8 +1102,13 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, info->control.vif = &tx->sdata->vif; info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; __skb_queue_tail(&tid_tx->pending, skb); + if (skb_queue_len(&tid_tx->pending) > STA_MAX_TX_BUFFER) + purge_skb = __skb_dequeue(&tid_tx->pending); } spin_unlock(&tx->sta->lock); + + if (purge_skb) + dev_kfree_skb(purge_skb);Shouldn't we stop the netdev queues or something instead?
As discussed privately (because I was unable to use the mail client on my mobile phone
correctly :) ) it would be possible to stop the netdev queues instead of dropping frames for
this STA/TID here.
But since the situation can also be triggered externally (by delaying the ADDBA response
for example) I think stopping the netdev queues in this case is problematic as it will affect
all STAs/TIDs and not only the one.
Hence, I still think the taken approach is reasonable.
Helmut
I haven't come up with a cleaner solution either for FreeBSD/ath/net80211 at the moment.
Right now, if you try establishing an aggregation session by flooding 250+ Mbit of UDP, you can easily allocate all the ath_buf's before the driver gets a chance to send the addba. Or, the addba fails but before that retransmission occurs, another UDP frame has eaten up another mbuf/ath_buf.
I'm totally open to a better idea/solution. Even if I delay allocating ath_buf's until actual packet TX, that doesn't necessarily stop mbuf exhaustion from occuring, which is in line with what you see you're seeing in Linux.
My temporarily solution is likely to fail datapath TX at say, 70% of ath_buf's being allocated, allowing the other 30% for whatever management traffic needs to occur.
(That said, what may be nice is applying backpressure to the source interface of the frame(s), eg by sending PAUSE frames to the ethernet port(s), but that's just me..)
Adrian
Johannes Berg
maintainerQuoted 14 lines · Adrian Chadd
I haven't come up with a cleaner solution either for FreeBSD/ath/net80211 at the moment.
Right now, if you try establishing an aggregation session by flooding 250+ Mbit of UDP, you can easily allocate all the ath_buf's before the driver gets a chance to send the addba. Or, the addba fails but before that retransmission occurs, another UDP frame has eaten up another mbuf/ath_buf.
I'm totally open to a better idea/solution. Even if I delay allocating ath_buf's until actual packet TX, that doesn't necessarily stop mbuf exhaustion from occuring, which is in line with what you see you're seeing in Linux.
Quoted 7 lines
My temporarily solution is likely to fail datapath TX at say, 70% of ath_buf's being allocated, allowing the other 30% for whatever management traffic needs to occur.
(That said, what may be nice is applying backpressure to the source interface of the frame(s), eg by sending PAUSE frames to the ethernet port(s), but that's just me..)
That would happen from the bridging code when the interface queues are stopped & get full, right?
johannes
Quoted 6 lines · Johannes Berg
Quoted 3 lines
(That said, what may be nice is applying backpressure to the source interface of the frame(s), eg by sending PAUSE frames to the ethernet port(s), but that's just me..)
That would happen from the bridging code when the interface queues are stopped & get full, right?
Sure, as long as the queues aren't too full. I haven't looked into whether openwrt sends PAUSE frames - Felix?
Adrian