On 4/10/2019 2:10 PM, Paras Jha wrote: > Hi all, > > I've been chasing down a strange issue related to rte_kni_tx_burst. > > My application calls rte_kni_rx_burst, which allocates from a discrete mbuf > pool using kni_allocate_mbufs. That traffic is immediately sent to > rte_eth_tx_burst which does not seem to be freeing mbufs even upon > succesful completion. > > My application follows the standard model of freeing mbufs only if the > number of tx mbufs is less than the rx mbufs - however, after sending as > many mbufs as there are in the pool, I get KNI: Out of memory soon after > when calling rte_kni_rx_burst > > My concern is that if I free all mbufs allocated by the KNI during > rte_kni_rx_burst the application seems to work as intended without memory > leaks, even though this goes against how the actual PMDs work. Is this a > bug, or intended behavior? The documented examples on the DPDK website seem > to only free mbufs if it fails to send, even with the KNI example.
The behavior in the KNI sample application is correct thing to do, free only the mbufs failed to Tx. As far as I understand you are doing same thing as the kni sample app, so it should be OK, sample app works fine. 'rte_eth_tx_burst()' sends packets to the kernel, so it shouldn't free the mbufs, right, userspace can't know when kernel side will be done with them. When kernel side is done, it puts the mbufs into 'free_q' fifo, 'kni_free_mbufs()' pulls the mbuf from 'free_q' fifo and frees them. So the mbufs sent via 'rte_eth_tx_burst()' freed asynchronously. I hope this helps.