From nobody Mon Jun 8 07:22:54 2026 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (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 BA8511C695 for ; Fri, 5 Jun 2026 00:56:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621007; cv=none; b=jq6V84QZyAGfkg52ZoQbSk1mBA49QZ18lTj0GUh0EyjT/r1XUHsOgr0l+s0ZB+eA3N0KF6dVNraYDv0ayTU/PZcvRs3e0ZJJg8EZ0pZx9fm7e+WO4pZ3ZbH3aZYwCZFlWyPKNeTuHN/UVRJmgU5YLan7fnSBR+Swo5sZXx6HdOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780621007; c=relaxed/simple; bh=sBwl+Fi0WLsEJazzgdDRluTY8cehnwCnJ8Z0QQTVDw4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PS9vi5sjkh9uV0rLEWDZ359PWFLFQw4TPAoI8ajzel6Crw/ujnA3MzRXpNDwSjJsLV+WM9Eu6t/SjoxTVjnNQAGFUy0H67FljTPOG4u8XkhL3m6b45GtRHSWRp2VyN6mppxj7OYgwpEfLpj6D57PaHmSlyy8eU/JaCKTNbcA0UA= 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=nmG1juc5; arc=none smtp.client-ip=209.85.216.52 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="nmG1juc5" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-36b8d414666so854698a91.3 for ; Thu, 04 Jun 2026 17:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780621005; x=1781225805; 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=gAfj4+hTPcQlGT5Ck/A2gCMQLo9AWh/S4FyKvN7eEWo=; b=nmG1juc5y36pduzoULjhkN5qWirQW1DtuXHKFLKkackqbJzFYHFt9VJTUCCvlbWENS MtMCMUL98UbYIUqcCbRQ0aVYJ9uUE3Sz2qpi4kcf6bYSSTVRbjPGODbZvF9FIy81tdeZ vI14HjaMS4Igp6Qmz6Fb5K65gUbV19IXWEgQVcUzEMm+2yJAMqx/iorYG/J1gg9YpU8G EEduFBygrZX24d6q+8/DpC15q3f06TOL6TIHKK9lP8SD6x0gSekJgwwjGfL8kEL8dVKZ 7zCrWPdN5FHR8y80Ulm8FNrXpdCPrYcQljJfk/uZcfN4n1SEHXfa8CBLEQDnVSnpj50g NEqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780621005; x=1781225805; 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=gAfj4+hTPcQlGT5Ck/A2gCMQLo9AWh/S4FyKvN7eEWo=; b=NO2dvGbq5udGHo7qT9vUQAbUhVV6XAdyd0ojJbWxKlHCrLd9mnM8jjRdK915S3Vr+C Oi3TfdtiGu1cwKoWipjmrac86R70xmM8UtFaeThG1WwVMfx5HkwPqeztCuvukB0O6WQC MW/bDCf4+Jc6CsYwGQz9NVvzOvwaA9hl4inQ+pKzI9A7RVrX39PyXKLz71v9K7FCO/S4 SsjzjI9hlz+9RSVe3NWktdmLTh0ZwdsygUa/jdHQ4BWyP0SUak2HJ9NRxwC7oMInpufM GHPKRUzMWznQg6N3p4a6cOYR1kFCocly6JSQfYKM4QQXcY0PS63T2WhVtVvLIj2U2MrK kvwQ== X-Forwarded-Encrypted: i=1; AFNElJ8ASagsesGzryShTlAtJ2uQ0cvVmCmyuIhV8STcdJOzryalZzi6dxIGcF7cFLEpuztFoeGfS12tioH1yYY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywcj6G9aPT5pw6eaZmwwHIQPY52xzB+3QI3Rs4j4VIniuK/HVU1 U1hLQEJUfALFCUQ/y/n98uVTOOK/fDCRhEfIraxE0zvGm8ZXWigdmXhO X-Gm-Gg: Acq92OFvRxf5gYqF/8Rr6lZonRbhFBKJ+DqxVrPjm2PGv5oxTy+QQxzrrWBYH5doCMu rvJrfJV2N+nCWKWzDZQwkYawylRKnh8xwnhJk1B+oAJIV0P6cut7fWenlG06PlBxkS6yB4igPJA zEu2Hx61w5CMJvgZ6mtGRKgqNolaOiBuFhue5K9hVYSnJt37Rrd4CC/MC+iZ6iew5iug7slguYP uPobCqvJqjuUnnQ8IgY53TWoBgUeB6ho1Mb9rP1pH6Z8LvqdxyAxLJwJdpVw0FhXCISigsUih6G LXU26kIQWseOEXJ72v4c2z8suGfPtPwSAd1yssul8BLBX3KmQyUqp/cdCfgifq6UlI2odN/kfJZ lnFhJN72wuVIvQQFHoROHk+od9Q1S+3NbSA0aVAoLOrLjSx8vhiNwKp80a9y5yPuxJrhBE9qm+z EwCE24WXL/TGi9AxHkjTkJd+0s2iAS2YatVwiiHsBrHIxuVqduNhFjRnxJIYPHmtayZBd6BFB4W 5i9m3+xcTOsxUM3l4LhGVoNeOcA53UamhBZpbS1Qygvjg== X-Received: by 2002:a17:90b:4b87:b0:368:b01c:85a0 with SMTP id 98e67ed59e1d1-370f0b54dc0mr1064206a91.14.1780621004831; Thu, 04 Jun 2026 17:56:44 -0700 (PDT) Received: from ryzen ([2601:644:8000:5b5d:7285:c2ff:fe45:8a32]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36f68b03ef6sm4516829a91.0.2026.06.04.17.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 17:56:44 -0700 (PDT) From: Rosen Penev To: linux-wireless@vger.kernel.org Cc: Johannes Berg , linux-kernel@vger.kernel.org (open list) Subject: [PATCHv2 wireless-next] wifi: mac80211: fold tid_ampdu_rx allocations into a flexible array Date: Thu, 4 Jun 2026 17:56:27 -0700 Message-ID: <20260605005627.317194-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 --- v2: use anonymous struct to combine allocations net/mac80211/agg-rx.c | 22 +++------------------- net/mac80211/rx.c | 14 +++++++------- net/mac80211/sta_info.h | 12 +++++++----- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c index cecd1c917e45..1a5647ddd30d 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..3ab77fafd95c 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,9 @@ 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: reorder buffer entries, each with &sk_buff_head @reorder[].buf + * and jiffies @reorder[].time. An MPDU may be an A-MSDU with individually + * reported subframes. * * This structure's lifetime is managed by RCU, assignments to * the array holding it must hold the aggregation mutex. @@ -241,8 +241,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 +254,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