Skip to content

Commit 3ff23cd

Browse files
tohojojmberg-intel
authored andcommitted
mac80211: Set lower memory limit for non-VHT devices
Small devices can run out of memory from queueing too many packets. If VHT is not supported by the PHY, having more than 4 MBytes of total queue in the TXQ intermediate queues is not needed, and so we can safely limit the memory usage in these cases and avoid OOM. Signed-off-by: Toke Høiland-Jørgensen <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 2a4e675 commit 3ff23cd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

net/mac80211/tx.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,8 @@ int ieee80211_txq_setup_flows(struct ieee80211_local *local)
14331433
struct fq *fq = &local->fq;
14341434
int ret;
14351435
int i;
1436+
bool supp_vht = false;
1437+
enum nl80211_band band;
14361438

14371439
if (!local->ops->wake_tx_queue)
14381440
return 0;
@@ -1441,6 +1443,23 @@ int ieee80211_txq_setup_flows(struct ieee80211_local *local)
14411443
if (ret)
14421444
return ret;
14431445

1446+
/*
1447+
* If the hardware doesn't support VHT, it is safe to limit the maximum
1448+
* queue size. 4 Mbytes is 64 max-size aggregates in 802.11n.
1449+
*/
1450+
for (band = 0; band < NUM_NL80211_BANDS; band++) {
1451+
struct ieee80211_supported_band *sband;
1452+
1453+
sband = local->hw.wiphy->bands[band];
1454+
if (!sband)
1455+
continue;
1456+
1457+
supp_vht = supp_vht || sband->vht_cap.vht_supported;
1458+
}
1459+
1460+
if (!supp_vht)
1461+
fq->memory_limit = 4 << 20; /* 4 Mbytes */
1462+
14441463
codel_params_init(&local->cparams);
14451464
local->cparams.interval = MS2TIME(100);
14461465
local->cparams.target = MS2TIME(20);

0 commit comments

Comments
 (0)