All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@amd.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Yuying Zhang <yuying.zhang@intel.com>,
	Robin Jarry <rjarry@redhat.com>
Subject: [PATCH 3/6] app/testpmd: bulk free mbufs
Date: Tue, 24 Jan 2023 11:47:39 +0100	[thread overview]
Message-ID: <20230124104742.1265439-4-david.marchand@redhat.com> (raw)
In-Reply-To: <20230124104742.1265439-1-david.marchand@redhat.com>

Use the bulk free helper.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 app/test-pmd/5tswap.c         | 4 +---
 app/test-pmd/csumonly.c       | 4 +---
 app/test-pmd/flowgen.c        | 8 ++------
 app/test-pmd/icmpecho.c       | 4 +---
 app/test-pmd/iofwd.c          | 4 +---
 app/test-pmd/macfwd.c         | 4 +---
 app/test-pmd/macswap.c        | 4 +---
 app/test-pmd/noisy_vnf.c      | 7 ++-----
 app/test-pmd/rxonly.c         | 4 +---
 app/test-pmd/shared_rxq_fwd.c | 3 +--
 app/test-pmd/testpmd.c        | 4 +---
 app/test-pmd/txonly.c         | 4 +---
 12 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/app/test-pmd/5tswap.c b/app/test-pmd/5tswap.c
index e665643a65..0a3a897e7b 100644
--- a/app/test-pmd/5tswap.c
+++ b/app/test-pmd/5tswap.c
@@ -174,9 +174,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_rx)) {
 		fs->fwd_dropped += (nb_rx - nb_tx);
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_rx);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx);
 	}
 
 	return true;
diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c
index 700c79f122..07850501f4 100644
--- a/app/test-pmd/csumonly.c
+++ b/app/test-pmd/csumonly.c
@@ -1195,9 +1195,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_prep)) {
 		fs->fwd_dropped += (nb_prep - nb_tx);
-		do {
-			rte_pktmbuf_free(tx_pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_prep);
+		rte_pktmbuf_free_bulk(&tx_pkts_burst[nb_tx], nb_prep - nb_tx);
 	}
 
 	return true;
diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c
index f26fd830f1..b3bd4f7c65 100644
--- a/app/test-pmd/flowgen.c
+++ b/app/test-pmd/flowgen.c
@@ -75,7 +75,6 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 	uint16_t nb_dropped;
 	uint16_t nb_pkt;
 	uint16_t nb_clones = nb_pkt_flowgen_clones;
-	uint16_t i;
 	uint32_t retry;
 	uint64_t tx_offloads;
 	int next_flow = RTE_PER_LCORE(_next_flow);
@@ -86,8 +85,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 	inc_rx_burst_stats(fs, nb_rx);
 	fs->rx_packets += nb_rx;
 
-	for (i = 0; i < nb_rx; i++)
-		rte_pktmbuf_free(pkts_burst[i]);
+	rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
 
 	mbp = current_fwd_lcore()->mbp;
 	vlan_tci = ports[fs->tx_port].tx_vlan_id;
@@ -186,9 +184,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs)
 			next_flow += nb_flows_flowgen;
 
 		fs->fwd_dropped += nb_dropped;
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_pkt);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx);
 	}
 
 	RTE_PER_LCORE(_next_flow) = next_flow;
diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c
index cd984d1ffb..5ef1116141 100644
--- a/app/test-pmd/icmpecho.c
+++ b/app/test-pmd/icmpecho.c
@@ -500,9 +500,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
 		inc_tx_burst_stats(fs, nb_tx);
 		if (unlikely(nb_tx < nb_replies)) {
 			fs->fwd_dropped += (nb_replies - nb_tx);
-			do {
-				rte_pktmbuf_free(pkts_burst[nb_tx]);
-			} while (++nb_tx < nb_replies);
+			rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_replies - nb_tx);
 		}
 	}
 
diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c
index 8218bd6b4b..9d0af5f667 100644
--- a/app/test-pmd/iofwd.c
+++ b/app/test-pmd/iofwd.c
@@ -76,9 +76,7 @@ pkt_burst_io_forward(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_rx)) {
 		fs->fwd_dropped += (nb_rx - nb_tx);
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_rx);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx);
 	}
 
 	return true;
diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c
index c1b116e559..3a840247c7 100644
--- a/app/test-pmd/macfwd.c
+++ b/app/test-pmd/macfwd.c
@@ -107,9 +107,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_rx)) {
 		fs->fwd_dropped += (nb_rx - nb_tx);
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_rx);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx);
 	}
 
 	return true;
diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c
index 361341e075..14b3eefffd 100644
--- a/app/test-pmd/macswap.c
+++ b/app/test-pmd/macswap.c
@@ -86,9 +86,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs)
 	inc_tx_burst_stats(fs, nb_tx);
 	if (unlikely(nb_tx < nb_rx)) {
 		fs->fwd_dropped += (nb_rx - nb_tx);
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_rx);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_rx - nb_tx);
 	}
 
 	return true;
diff --git a/app/test-pmd/noisy_vnf.c b/app/test-pmd/noisy_vnf.c
index e2fecafeac..ecea51b603 100644
--- a/app/test-pmd/noisy_vnf.c
+++ b/app/test-pmd/noisy_vnf.c
@@ -111,11 +111,8 @@ do_retry(uint16_t nb_rx, uint16_t nb_tx, struct rte_mbuf **pkts,
 static uint32_t
 drop_pkts(struct rte_mbuf **pkts, uint16_t nb_rx, uint16_t nb_tx)
 {
-	if (nb_tx < nb_rx) {
-		do {
-			rte_pktmbuf_free(pkts[nb_tx]);
-		} while (++nb_tx < nb_rx);
-	}
+	if (nb_tx < nb_rx)
+		rte_pktmbuf_free_bulk(&pkts[nb_tx], nb_rx - nb_tx);
 
 	return nb_rx - nb_tx;
 }
diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c
index 375be990bd..ad4597cf9a 100644
--- a/app/test-pmd/rxonly.c
+++ b/app/test-pmd/rxonly.c
@@ -46,7 +46,6 @@ pkt_burst_receive(struct fwd_stream *fs)
 {
 	struct rte_mbuf  *pkts_burst[MAX_PKT_BURST];
 	uint16_t nb_rx;
-	uint16_t i;
 
 	/*
 	 * Receive a burst of packets.
@@ -58,8 +57,7 @@ pkt_burst_receive(struct fwd_stream *fs)
 		return false;
 
 	fs->rx_packets += nb_rx;
-	for (i = 0; i < nb_rx; i++)
-		rte_pktmbuf_free(pkts_burst[i]);
+	rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
 
 	return true;
 }
diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c
index 4b3a87a3ba..4902ec407e 100644
--- a/app/test-pmd/shared_rxq_fwd.c
+++ b/app/test-pmd/shared_rxq_fwd.c
@@ -53,8 +53,7 @@ forward_sub_burst(struct fwd_stream *src_fs, uint16_t port, uint16_t nb_rx,
 	} else {
 		/* Source stream not found, drop all packets. */
 		src_fs->fwd_dropped += nb_rx;
-		while (nb_rx > 0)
-			rte_pktmbuf_free(pkts[--nb_rx]);
+		rte_pktmbuf_free_bulk(pkts, nb_rx);
 	}
 }
 
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 9afc107975..dab67bce5c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2196,7 +2196,6 @@ flush_fwd_rx_queues(void)
 	portid_t port_id;
 	queueid_t rxq;
 	uint16_t  nb_rx;
-	uint16_t  i;
 	uint8_t   j;
 	uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
 	uint64_t timer_period;
@@ -2229,8 +2228,7 @@ flush_fwd_rx_queues(void)
 				do {
 					nb_rx = rte_eth_rx_burst(port_id, rxq,
 						pkts_burst, MAX_PKT_BURST);
-					for (i = 0; i < nb_rx; i++)
-						rte_pktmbuf_free(pkts_burst[i]);
+					rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
 
 					cur_tsc = rte_rdtsc();
 					diff_tsc = cur_tsc - prev_tsc;
diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 23e51a1bec..63ad5e69bf 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -418,9 +418,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
 			       (unsigned) nb_pkt, (unsigned) nb_tx,
 			       (unsigned) (nb_pkt - nb_tx));
 		fs->fwd_dropped += (nb_pkt - nb_tx);
-		do {
-			rte_pktmbuf_free(pkts_burst[nb_tx]);
-		} while (++nb_tx < nb_pkt);
+		rte_pktmbuf_free_bulk(&pkts_burst[nb_tx], nb_pkt - nb_tx);
 	}
 
 	return true;
-- 
2.39.1


  parent reply	other threads:[~2023-01-24 10:48 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 10:47 [PATCH 0/6] Testpmd code cleanup David Marchand
2023-01-24 10:47 ` [PATCH 1/6] app/testpmd: factorize core cycles record David Marchand
2023-02-14 18:14   ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 2/6] app/testpmd: don't send unprepared packets David Marchand
2023-02-14 18:14   ` Ferruh Yigit
2023-01-24 10:47 ` David Marchand [this message]
2023-02-14 18:14   ` [PATCH 3/6] app/testpmd: bulk free mbufs Ferruh Yigit
2023-01-24 10:47 ` [PATCH 4/6] app/testpmd: factorize fwd engine init David Marchand
2023-02-14 18:14   ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 5/6] app/testpmd: factorize fwd engine Rx David Marchand
2023-02-14 18:15   ` Ferruh Yigit
2023-01-24 10:47 ` [PATCH 6/6] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-14 11:03   ` Singh, Aman Deep
2023-02-14 18:17     ` Ferruh Yigit
2023-02-16  8:01       ` Singh, Aman Deep
2023-02-16 10:07         ` Ferruh Yigit
2023-02-14 18:16   ` Ferruh Yigit
2023-02-20 16:33     ` David Marchand
2023-01-25 13:50 ` [PATCH 0/6] Testpmd code cleanup Robin Jarry
2023-02-14 18:22   ` Ferruh Yigit
2023-02-20 15:02     ` David Marchand
2023-02-20 16:40 ` [PATCH v2 0/9] " David Marchand
2023-02-20 16:40   ` [PATCH v2 1/9] app/testpmd: fix Tx preparation in checksum engine David Marchand
2023-02-20 16:40   ` [PATCH v2 2/9] app/testpmd: fix packet count in ieee15888 engine David Marchand
2023-02-20 16:40   ` [PATCH v2 3/9] app/testpmd: rework ieee1588 engine fwd configuration David Marchand
2023-02-24  9:11     ` Singh, Aman Deep
2023-02-20 16:40   ` [PATCH v2 4/9] app/testpmd: fix packet transmission in noisy VNF engine David Marchand
2023-02-20 16:40   ` [PATCH v2 5/9] app/testpmd: bulk free mbufs David Marchand
2023-02-20 16:41   ` [PATCH v2 6/9] app/testpmd: factorize core cycles record David Marchand
2023-02-20 16:41   ` [PATCH v2 7/9] app/testpmd: factorize fwd engine init David Marchand
2023-02-20 16:41   ` [PATCH v2 8/9] app/testpmd: factorize fwd engine Rx David Marchand
2023-02-20 16:41   ` [PATCH v2 9/9] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-20 18:34 ` [PATCH v3 0/9] Testpmd code cleanup David Marchand
2023-02-20 18:34   ` [PATCH v3 1/9] app/testpmd: fix Tx preparation in checksum engine David Marchand
2023-02-20 18:34   ` [PATCH v3 2/9] app/testpmd: fix packet count in ieee15888 engine David Marchand
2023-02-24  8:24     ` Singh, Aman Deep
2023-02-20 18:34   ` [PATCH v3 3/9] app/testpmd: rework ieee1588 engine fwd configuration David Marchand
2023-02-28 18:50     ` Ferruh Yigit
2023-02-20 18:34   ` [PATCH v3 4/9] app/testpmd: fix packet transmission in noisy VNF engine David Marchand
2023-02-28 18:51     ` Ferruh Yigit
2023-02-20 18:34   ` [PATCH v3 5/9] app/testpmd: bulk free mbufs David Marchand
2023-02-20 18:45     ` Stephen Hemminger
2023-02-20 18:34   ` [PATCH v3 6/9] app/testpmd: factorize core cycles record David Marchand
2023-02-20 18:35   ` [PATCH v3 7/9] app/testpmd: factorize fwd engine init David Marchand
2023-02-20 18:35   ` [PATCH v3 8/9] app/testpmd: factorize fwd engine Rx David Marchand
2023-02-20 18:35   ` [PATCH v3 9/9] app/testpmd: factorize fwd engine Tx David Marchand
2023-02-28 18:35     ` Ferruh Yigit
2023-02-28 18:54   ` [PATCH v3 0/9] Testpmd code cleanup Ferruh Yigit

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=20230124104742.1265439-4-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=rjarry@redhat.com \
    --cc=yuying.zhang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.