Force driver to free sent buffers?
Stephen Hemminger
stephen at networkplumber.org
Mon Oct 7 00:18:20 CEST 2024
On Sun, 6 Oct 2024 12:38:56 -0400
Alan Beadle <ab.beadle at gmail.com> wrote:
> Hi everyone,
>
> Based on my thread from last week, I am using rte_mbuf_refcnt_update()
> to increment the mbuf refcnts so that the driver will not free buffers
> before my local readers are done with them.
> I am also maintaining a queue of mbufs that local readers are finished
> with, and periodically using rte_mbuf_refcnt_read() to see if the
> refcnt is 1 yet, so that they can be freed or reused.
>
> An aside: Is there any problem with reuse of mbufs? Without actually
> freeing and re-allocating it, that is? I plan to do this in order to
> avoid having to link new mbufs to other reused data structures in my
> application.
>
> The current problem is as follows: My application has a separate
> unrelated heap (special purpose and bounded in size) and this heap
> runs out of memory after a brief time because of having to track so
> many unfreed mbufs. It appears that none of the mbufs are being freed
> by the driver after being sent, and it looks like it won't free them
> until it runs out of descriptors, which is too long for my situation.
>
> I have confirmed that the packets are being sent (received on other PC
> with wireshark) and should be freeable. Is there a way to force the
> driver to free sent mbufs earlier than when it runs out of
> descriptors?
>
> Thanks,
> -Alan
Drivers are free to hold onto transmitted mbuf's indefinitely.
Since DPDK does not use interrupts for normal Tx, the driver has to defer
doing cleaning up either on next Tx or sometimes Rx. There is a Tx threshold
that may impact some drivers, but not all.
More information about the users
mailing list