On Tue, Jan 10, 2023 at 9:27 PM Ilya Maximets <[email protected]> wrote: > > On 1/10/23 19:27, Kevin Traynor wrote: > > On 09/01/2023 18:28, Ilya Maximets wrote: > >> rte_pktmbuf_free_bulk() function was introduced in 19.11 and became > >> stable in 21.11. Use it to free arrays of mbufs instead of freeing > >> packets one by one. > >> > >> In simple V2V testing with 64B packets, 2 PMD threads and bidirectional > >> traffic this change improves performance by 3.5 - 4.5 %. > >> > >> Signed-off-by: Ilya Maximets <[email protected]> > >> --- > >> lib/netdev-dpdk.c | 13 +++---------- > >> 1 file changed, 3 insertions(+), 10 deletions(-) > >> > >> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c > >> index 5e2d64651..28a04bb7f 100644 > >> --- a/lib/netdev-dpdk.c > >> +++ b/lib/netdev-dpdk.c > >> @@ -2286,13 +2286,8 @@ netdev_dpdk_eth_tx_burst(struct netdev_dpdk *dev, > >> int qid, > >> } > >> if (OVS_UNLIKELY(nb_tx != cnt)) { > >> - /* Free buffers, which we couldn't transmit, one at a time (each > >> - * packet could come from a different mempool) */ > >> - int i; > >> - > >> - for (i = nb_tx; i < cnt; i++) { > >> - rte_pktmbuf_free(pkts[i]); > >> - } > >> + /* Free buffers, which we couldn't transmit. */ > >> + rte_pktmbuf_free_bulk(&pkts[nb_tx], cnt - nb_tx); > > > > Is this API ok with freeing pkts from different mempools? > > > > The documentation seems to imply it is, but I wasn't sure from looking > > at the code - specifically that there is an additional > > rte_mempool_put_bulk() > > for a single mempool outside the loop. > > It should work for mbufs from different pools. The function collects > mbufs into the 'pending' array and calls rte_mempool_put_bulk() once > it hits mbuf from a different pool. See __rte_pktmbuf_free_seg_via_array(). > > The additional rte_mempool_put_bulk() in the end takes care of remaining > mbufs that are not freed by __rte_pktmbuf_free_seg_via_array(). These > all should be from the same pool. > > There is also a unit test - test_pktmbuf_pool_bulk() - that tests with > different mempools. > > > I vaguely remember that there was an API to bulk free mbufs that was > suitable only when all mbufs are from the same pool. And the comment > that I'm removing here in the code also suggests that. But I don't > remember what that was.
The only thing that comes to mind if a direct use of mempool bulk put. A lot of drivers have opencoded (for quite some time) the same logic than what rte_pktmbuf_free_bulk does (this is in my ever growing todolist to cleanup all of this...). -- David Marchand _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
