From f82067c4d51b332c1e4163117bee5a4f327f9be4 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 29 Dec 2020 12:08:59 -0800 Subject: [PATCH] pdump: free mbuf in bulk MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use rte_pktmbuf_free_bulk instead of loop when freeing packets. Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup --- app/pdump/main.c | 8 ++++---- lib/librte_pdump/rte_pdump.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index b34bf33531..63bbe65cd8 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -477,10 +477,10 @@ pdump_rxtx(struct rte_ring *ring, uint16_t vdev_id, struct pdump_stats *stats) stats->tx_pkts += nb_in_txd; if (unlikely(nb_in_txd < nb_in_deq)) { - do { - rte_pktmbuf_free(rxtx_bufs[nb_in_txd]); - stats->freed_pkts++; - } while (++nb_in_txd < nb_in_deq); + unsigned int drops = nb_in_deq - nb_in_txd; + + rte_pktmbuf_free_bulk(&rxtx_bufs[nb_in_txd], drops); + stats->freed_pkts += drops; } } } diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index b3c8d5ce43..3c11bd795b 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -93,11 +93,11 @@ pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) ring_enq = rte_ring_enqueue_burst(ring, (void *)dup_bufs, d_pkts, NULL); if (unlikely(ring_enq < d_pkts)) { + unsigned int drops = d_pkts - ring_enq; + PDUMP_LOG(DEBUG, "only %d of packets enqueued to ring\n", ring_enq); - do { - rte_pktmbuf_free(dup_bufs[ring_enq]); - } while (++ring_enq < d_pkts); + rte_pktmbuf_free_bulk(&dup_bufs[ring_enq], drops); } } -- 2.20.1