On 1/11/23 10:42, Kevin Traynor wrote:
> On 10/01/2023 20:27, Ilya Maximets 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.
>>
> 
> got it - thanks.
> 
>> 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.
>>
>> Best regards, Ilya Maximets.
>>
> 
> Acked-by: Kevin Traynor <[email protected]>
> 
> 


Thanks, David and Kevin!  Applied to master.

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to