From nobody Mon Jun 8 04:24:37 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BB0922D7A1 for ; Sun, 7 Jun 2026 02:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780798386; cv=none; b=GrGXWe0XddoNg5LkePjdgpxl2Eo6iFxAnDJL/om8WzCvwPLxW+MZtbpzFoxK2M8XYU4GLWukDpcpHi3NjhxdzxpubPbikWPoOkKLxcmCKW55/PJDssEYxguPWwYt4InlDYP+d+ZZ+93bWRCULYL4efCySV+Z+L3OIpSfg/KT7o4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780798386; c=relaxed/simple; bh=uQsMeEbR6kDv0rOCTarB+WL0+qAK97AZ0MjgyylTOhA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RmS6YqBxEaEaFBb/yMxSS26FhDQa3RxI7hGV70Ps2pN1aNtPIaWNZYjVvmHR59UBC0wH4NzAvTWMfelToYKkOdImByDehF/DLKm+abQSPZkFsrElRdEbQ46zHG8RsJkpY2J4+iZFIIsjquI/XFrejGU+cbQKfAqZ5yU9O/klKmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ww0Zro3k; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ww0Zro3k" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c85ba774551so1153494a12.0 for ; Sat, 06 Jun 2026 19:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780798383; x=1781403183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iBfzAvBmHxoTdEDnxAcg3ks9n3jJCgw3BECtZF4cCsY=; b=Ww0Zro3kM9I9PiaBwI5tPtrEhm3dPpwJcwIRUlP+5b+ispwNgLBbFOAJlEZdVMj+3H +QrXuwQhn7Vg91+5th53nLKxrVgx8DbFVe6R6v86ayhGsk0zSKaypfgXIwCaViM3oW98 DMcL1GI6294P911Va9m5jDrZzNKO/l3Cq4hAmTbfCYtR08P+GGalJ6nnEszdwv1g6nE0 1NChR9bTjSb0qRxNN33/vJi5SB7xayc1lLohodeCgMwfWhfMzUqJRvWXWKTuymIsrpc1 0B8kgligX17ko/2NUhA25zMK9c2gePGK9kfJLKmAPdyTdQLfVg9wWI2SJkHBH46KBXwu yD0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780798383; x=1781403183; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iBfzAvBmHxoTdEDnxAcg3ks9n3jJCgw3BECtZF4cCsY=; b=rWslfbFkUhb71UGqkdzHRkHAB8JY6Pf54ZzxPHKIJwCpXNEDac+TumzJJG3wuYv2vp Vqlq5ihsMyBHH9bFibLe9lmsxiNAYUqgjUutvRt9ZBR1ery2v5a8Czb5nYfik5qD2MUQ MT1maILo0QnjFCeXcM9XQyuWe26mCfYUTw5F3tn9V4iNrSnj+yFoXUWkD8/ujTdCfXKJ bppkxYXlTY9m/Es2co8Rp6Rt8VqWb93eVB8LPSbWR3KtZOE/Cfey34Uvzu2ZAMya6Bqr o2s8RxdJaacuyapCRGQxhZqcH47d+1sPXIIusIUhZvczC/tdFN+zIpSohxUoqpG3siTT e/KA== X-Forwarded-Encrypted: i=1; AFNElJ+8PBPuyXyB/p4qBc5zcJYzolJCXxFqMwuIz8qODxlhKUSbHQxUfS9jar4yTKQDDWZSHIg963Ci2GMlKbE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxuo8IJzZ7rzQ8BE6J+pnRzQhgzgZU5Wco0jyo+4CEGQkFNz/4r R1xy3zjAJU6r9+UqZ321e4QlAk65hZLflLxCyzEUZdD9oWqB6fpOGRSsBkzKhw== X-Gm-Gg: Acq92OFqC7i6lSHqNtofsH4EaV7OlJuDYL8ml5oZZ8UhN2PaHX9k8IEZ5QYbnS6tUJJ +h/t4HHGaZhxhnyXv15nf7Nw5aNZIXQnoTUhuYDXBNrh1J+kNvteM0oZKMRX5RhlFalvR6whvjj Vk6AxfIOP9l2xy+FrzFUvi50/8q9517G/Fzcfl3gHmUnEeBS2txWU6gOuNGNJSe2FNUvy5DJzt6 CRq36pI6TtqqydfOg++JG5brpxW5PNEe1ydpbwJDSXsSgz4pkTX4X3jc7Yo6aZ9sfBAKV3OEVYO xE/iPEyjb1yCKZZjJAg2VGn+jLpRBFxxU454bW9gFo3m9/UcWgEBeT4Q5IxKnEhrEBgy3mPypIn LSAp8MqrgpsIE0OLQEanuNQoeIIgIqspP9XQkN0L7HhzPm3BgyOpzXVmDGjz5isMvGe/foKSimk agPQ58udZcJmV36g08p9dTnyiiWWmugDQkhB60MhnTHJM0PL+vBgU5PSO65z9ksqnFT4hEzE39z Y+9wIZ5lC7ybRgnALzeqKiYXjuUoo6wMFZRkV3qWQUnig== X-Received: by 2002:a05:6a00:3e22:b0:842:4af4:3099 with SMTP id d2e1a72fcca58-842b0e6a336mr9677898b3a.20.1780798383394; Sat, 06 Jun 2026 19:13:03 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8428706fa9asm13184098b3a.45.2026.06.06.19.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2026 19:13:02 -0700 (PDT) From: Rosen Penev To: linux-wireless@vger.kernel.org Cc: Johannes Berg , linux-kernel@vger.kernel.org (open list) Subject: [PATCHv3 wireless-next] wifi: mac80211: fold tid_ampdu_rx allocations into a flexible array Date: Sat, 6 Jun 2026 19:12:45 -0700 Message-ID: <20260607021245.6470-1-rosenp@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert the separately-allocated reorder_buf pointer to a C99 flexible array member at the end of struct tid_ampdu_rx, with both the sk_buff_head and the jiffies timestamp in each array element. This collapses three allocations into one and removes the corresponding kfree() pairs from the error and free paths. Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev --- v3: Fix kernel-doc v2: use anonymous struct to combine allocations net/mac80211/agg-rx.c | 22 +++------------------- net/mac80211/rx.c | 14 +++++++------- net/mac80211/sta_info.h | 13 ++++++++----- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index 0140ac826b23..9629e00069a1 100644 --- a/net/mac80211/agg-rx.c +++ b/net/mac80211/agg-rx.c @@ -49,9 +49,7 @@ static void ieee80211_free_tid_rx(struct rcu_head *h) int i; for (i =3D 0; i < tid_rx->buf_size; i++) - __skb_queue_purge(&tid_rx->reorder_buf[i]); - kfree(tid_rx->reorder_buf); - kfree(tid_rx->reorder_time); + __skb_queue_purge(&tid_rx->reorder[i].buf); kfree(tid_rx); } @@ -412,7 +410,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *s= ta, } /* prepare A-MPDU MLME for Rx aggregation */ - tid_agg_rx =3D kzalloc_obj(*tid_agg_rx); + tid_agg_rx =3D kzalloc_flex(*tid_agg_rx, reorder, buf_size); if (!tid_agg_rx) goto end; @@ -426,27 +424,13 @@ void __ieee80211_start_rx_ba_session(struct sta_info = *sta, timer_setup(&tid_agg_rx->reorder_timer, sta_rx_agg_reorder_timer_expired, 0); - /* prepare reordering buffer */ - tid_agg_rx->reorder_buf =3D - kzalloc_objs(struct sk_buff_head, buf_size); - tid_agg_rx->reorder_time =3D - kcalloc(buf_size, sizeof(unsigned long), GFP_KERNEL); - if (!tid_agg_rx->reorder_buf || !tid_agg_rx->reorder_time) { - kfree(tid_agg_rx->reorder_buf); - kfree(tid_agg_rx->reorder_time); - kfree(tid_agg_rx); - goto end; - } - for (i =3D 0; i < buf_size; i++) - __skb_queue_head_init(&tid_agg_rx->reorder_buf[i]); + __skb_queue_head_init(&tid_agg_rx->reorder[i].buf); ret =3D drv_ampdu_action(local, sta->sdata, ¶ms); ht_dbg(sta->sdata, "Rx A-MPDU request on %pM tid %d result %d\n", sta->sta.addr, tid, ret); if (ret) { - kfree(tid_agg_rx->reorder_buf); - kfree(tid_agg_rx->reorder_time); kfree(tid_agg_rx); goto end; } diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index db421edfd54c..fb9a3574afe9 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -1188,7 +1188,7 @@ static ieee80211_rx_result ieee80211_rx_mesh_check(st= ruct ieee80211_rx_data *rx) static inline bool ieee80211_rx_reorder_ready(struct tid_ampdu_rx *tid_agg= _rx, int index) { - struct sk_buff_head *frames =3D &tid_agg_rx->reorder_buf[index]; + struct sk_buff_head *frames =3D &tid_agg_rx->reorder[index].buf; struct sk_buff *tail =3D skb_peek_tail(frames); struct ieee80211_rx_status *status; @@ -1211,7 +1211,7 @@ static void ieee80211_release_reorder_frame(struct ie= ee80211_sub_if_data *sdata, int index, struct sk_buff_head *frames) { - struct sk_buff_head *skb_list =3D &tid_agg_rx->reorder_buf[index]; + struct sk_buff_head *skb_list =3D &tid_agg_rx->reorder[index].buf; struct sk_buff *skb; struct ieee80211_rx_status *status; @@ -1290,14 +1290,14 @@ static void ieee80211_sta_reorder_release(struct ie= ee80211_sub_if_data *sdata, continue; } if (skipped && - !time_after(jiffies, tid_agg_rx->reorder_time[j] + + !time_after(jiffies, tid_agg_rx->reorder[j].time + HT_RX_REORDER_BUF_TIMEOUT)) goto set_release_timer; /* don't leave incomplete A-MSDUs around */ for (i =3D (index + 1) % tid_agg_rx->buf_size; i !=3D j; i =3D (i + 1) % tid_agg_rx->buf_size) - __skb_queue_purge(&tid_agg_rx->reorder_buf[i]); + __skb_queue_purge(&tid_agg_rx->reorder[i].buf); ht_dbg_ratelimited(sdata, "release an RX reorder frame due to timeout on earlier frames\n"); @@ -1331,7 +1331,7 @@ static void ieee80211_sta_reorder_release(struct ieee= 80211_sub_if_data *sdata, if (!tid_agg_rx->removed) mod_timer(&tid_agg_rx->reorder_timer, - tid_agg_rx->reorder_time[j] + 1 + + tid_agg_rx->reorder[j].time + 1 + HT_RX_REORDER_BUF_TIMEOUT); } else { timer_delete(&tid_agg_rx->reorder_timer); @@ -1426,9 +1426,9 @@ static bool ieee80211_sta_manage_reorder_buf(struct i= eee80211_sub_if_data *sdata } /* put the frame in the reordering buffer */ - __skb_queue_tail(&tid_agg_rx->reorder_buf[index], skb); + __skb_queue_tail(&tid_agg_rx->reorder[index].buf, skb); if (!(status->flag & RX_FLAG_AMSDU_MORE)) { - tid_agg_rx->reorder_time[index] =3D jiffies; + tid_agg_rx->reorder[index].time =3D jiffies; tid_agg_rx->stored_mpdu_num++; ieee80211_sta_reorder_release(sdata, tid_agg_rx, frames); } diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 26138934b72e..b5f1310d2cd6 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -207,11 +207,8 @@ struct tid_ampdu_tx { /** * struct tid_ampdu_rx - TID aggregation information (Rx). * - * @reorder_buf: buffer to reorder incoming aggregated MPDUs. An MPDU may = be an - * A-MSDU with individually reported subframes. * @reorder_buf_filtered: bitmap indicating where there are filtered frame= s in * the reorder buffer that should be ignored when releasing frames - * @reorder_time: jiffies when skb was added * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value) * @reorder_timer: releases expired frames from the reorder buffer. * @sta: station we are attached to @@ -228,6 +225,10 @@ struct tid_ampdu_tx { * and ssn. * @removed: this session is removed (but might have been found due to RCU) * @started: this session has started (head ssn or higher was received) + * @reorder: array containing a buffer with a jiffies component + * @reorder.buf: buffer to reorder incoming aggregated MPDUs. An MPDU may = be an + * A-MSDU with individually reported subframes. + * @reorder.time: jiffies when skb was added * * This structure's lifetime is managed by RCU, assignments to * the array holding it must hold the aggregation mutex. @@ -241,8 +242,6 @@ struct tid_ampdu_rx { struct rcu_head rcu_head; spinlock_t reorder_lock; u64 reorder_buf_filtered; - struct sk_buff_head *reorder_buf; - unsigned long *reorder_time; struct sta_info *sta; struct timer_list session_timer; struct timer_list reorder_timer; @@ -256,6 +255,10 @@ struct tid_ampdu_rx { u8 auto_seq:1, removed:1, started:1; + struct { + struct sk_buff_head buf; + unsigned long time; + } reorder[]; }; /** -- 2.54.0