On Thu, 4 May 2023 13:00:32 +0000 Yasin CANER <yasin.ca...@ulakhaberlesme.com.tr> wrote:
> In default-testing kni application works as below > > > 1. Call rte_kni_rx_burst function to get messages > 2. Then push to other KNI interface via rte_kni_tx_burst. There is no > memory-leak because kni_free_mbufs is called and freed unused allocations. > > On the other hand, in my scenario > > > 1. Call rte_kni_rx_burst func to get messages, burst_size is 32 but 1 > packet is received from Kernel > 2. Then try to free all messages via rte_pktmbuf_free > 3. Freed 1 unit and 31 unit is not freed. memory leak > > Other scenario, > > > 1. Call rte_kni_rx_burst func to get messages, burst_size is 32 but 1 > packet is received from Kernel > 2. Push to ethernet_device via rte_eth_tx_burst > 3. There is not any free operation by rte_eth_tx_burst > 4. Try to free via rte_pktmbuf_free > 5. 1 unit is freed 31 unit is left in memory. Still memory leak It looks like you are confused about the lifetime of mbufs, and the "ownership" of the mbuf. When you do kni_rx_burst, one mbuf is full of data and returned. The other 31 slots are not used. Only the first mbuf is valid. When mbuf is passed to another DPDK device driver for transmit. The mbuf is then owned by the device. This mbuf can not be freed until the device has completed DMA and is transmitting it. Also, many devices defer freeing transmit mbuf's as an optimization. There is some limited control over the transmit freeing via tx_free_thresh. See the DPDK programmers guide for more info: https://doc.dpdk.org/guides/prog_guide/poll_mode_drv.html