pdump: free mbuf in bulk
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 29 Dec 2020 20:08:59 +0000 (12:08 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 19 Jan 2021 14:24:46 +0000 (15:24 +0100)
Use rte_pktmbuf_free_bulk instead of loop when freeing
packets.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
app/pdump/main.c
lib/librte_pdump/rte_pdump.c

index b34bf33..63bbe65 100644 (file)
@@ -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;
                }
        }
 }
index b3c8d5c..3c11bd7 100644 (file)
@@ -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);
        }
 }