DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Subject: [PATCH 06/20] port: use rte_pktmbuf_free_bulk
Date: Fri,  8 May 2026 13:33:27 -0700	[thread overview]
Message-ID: <20260508203607.1003036-7-stephen@networkplumber.org> (raw)
In-Reply-To: <20260508203607.1003036-1-stephen@networkplumber.org>

Replace open-coded loop with rte_pktmbuf_free_bulk().

Generated by devtools/cocci/free_bulk.cocci.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/port/rte_port_fd.c              | 6 ++----
 lib/port/rte_swx_port_fd.c          | 8 ++------
 lib/port/rte_swx_port_source_sink.c | 6 +-----
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c
index dbc9efef1b..2b021710d4 100644
--- a/lib/port/rte_port_fd.c
+++ b/lib/port/rte_port_fd.c
@@ -212,8 +212,7 @@ send_burst(struct rte_port_fd_writer *p)
 
 	RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i);
 
-	for (i = 0; i < p->tx_buf_count; i++)
-		rte_pktmbuf_free(p->tx_buf[i]);
+	rte_pktmbuf_free_bulk(p->tx_buf, p->tx_buf_count);
 
 	p->tx_buf_count = 0;
 }
@@ -397,8 +396,7 @@ send_burst_nodrop(struct rte_port_fd_writer_nodrop *p)
 
 	RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i);
 
-	for (i = 0; i < p->tx_buf_count; i++)
-		rte_pktmbuf_free(p->tx_buf[i]);
+	rte_pktmbuf_free_bulk(p->tx_buf, p->tx_buf_count);
 
 	p->tx_buf_count = 0;
 }
diff --git a/lib/port/rte_swx_port_fd.c b/lib/port/rte_swx_port_fd.c
index 72783d2b0f..937b1e0945 100644
--- a/lib/port/rte_swx_port_fd.c
+++ b/lib/port/rte_swx_port_fd.c
@@ -73,14 +73,11 @@ static void
 reader_free(void *port)
 {
 	struct reader *p = port;
-	uint32_t i;
 
 	if (!p)
 		return;
 
-	for (i = 0; i < p->n_pkts; i++)
-		rte_pktmbuf_free(p->pkts[i]);
-
+	rte_pktmbuf_free_bulk(p->pkts, p->n_pkts);
 	free(p->pkts);
 	free(p);
 }
@@ -218,8 +215,7 @@ __writer_flush(struct writer *p)
 		(uint32_t)p->params.fd,
 		p->n_pkts);
 
-	for (i = 0; i < p->n_pkts; i++)
-		rte_pktmbuf_free(p->pkts[i]);
+	rte_pktmbuf_free_bulk(p->pkts, p->n_pkts);
 
 	p->n_pkts = 0;
 }
diff --git a/lib/port/rte_swx_port_source_sink.c b/lib/port/rte_swx_port_source_sink.c
index af8b9ec68d..f651d5b5ad 100644
--- a/lib/port/rte_swx_port_source_sink.c
+++ b/lib/port/rte_swx_port_source_sink.c
@@ -52,16 +52,12 @@ static void
 source_free(void *port)
 {
 	struct source *p = port;
-	uint32_t i;
 
 	if (!p)
 		return;
 
-	for (i = 0; i < p->n_pkts; i++)
-		rte_pktmbuf_free(p->pkts[i]);
-
+	rte_pktmbuf_free_bulk(p->pkts, p->n_pkts);
 	free(p->pkts);
-
 	free(p);
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-05-08 20:36 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 20:33 [PATCH 00/20] pktmbuf free bulk cleanups Stephen Hemminger
2026-05-08 20:33 ` [PATCH 01/20] devtools/cocci: add transform for rte_pktmbuf_free_bulk Stephen Hemminger
2026-05-08 20:33 ` [PATCH 02/20] eventdev: use rte_pktmbuf_free_bulk Stephen Hemminger
2026-05-08 20:33 ` [PATCH 03/20] gso: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 04/20] ip_frag: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 05/20] pipeline: " Stephen Hemminger
2026-05-08 20:33 ` Stephen Hemminger [this message]
2026-05-08 20:33 ` [PATCH 07/20] net/af_xdp: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 08/20] net/cnxk: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 09/20] net/pfe: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 10/20] net/virtio: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 11/20] net/zxdh: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 12/20] app/compress-perf: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 13/20] mbuf: allow NULL array in rte_pktmbuf_free_bulk Stephen Hemminger
2026-05-09  8:47   ` Morten Brørup
2026-05-09 15:46     ` Stephen Hemminger
2026-05-10 12:31       ` Morten Brørup
2026-05-10 15:21         ` Stephen Hemminger
2026-05-08 20:33 ` [PATCH 14/20] net/zxdh: remove unnecessary null check Stephen Hemminger
2026-05-08 20:33 ` [PATCH 15/20] net/ice: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 16/20] net/bnxt: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 17/20] test: use rte_pktmbuf_free_bulk Stephen Hemminger
2026-05-08 20:33 ` [PATCH 18/20] app/test-dma-perf: remove unnecessary null check Stephen Hemminger
2026-05-11  1:16   ` fengchengwen
2026-05-08 20:33 ` [PATCH 19/20] app/test-compress-perf: " Stephen Hemminger
2026-05-08 20:33 ` [PATCH 20/20] examples: use rte_pktmbuf_free_bulk Stephen Hemminger

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=20260508203607.1003036-7-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.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