DPDK 22.11 - How to fix memory leak for KNI - How to debug

Yasin CANER yasinncaner at gmail.com
Thu May 11 16:14:03 CEST 2023


Hello all,

 I fixed both bugs on my work computer. but it is hard to push a patch
because dpdk git has so many steps.

https://bugs.dpdk.org/show_bug.cgi?id=1227
https://bugs.dpdk.org/show_bug.cgi?id=1229

Best regards.

Yasin CANER <yasinncaner at gmail.com>, 9 May 2023 Sal, 14:13 tarihinde şunu
yazdı:

> Hello,
>
> I draw a flow via asciiflow to explain myself better. Problem is after
> transmitting packets(mbufs) , it never puts in the kni->free_q to back to
> the original pool. Each cycle, it allocates another 32 units that cause
> leaks. Or I am missing something.
>
> I already tried the rte_eth_tx_done_cleanup() function but it didn't fix
> anything.
>
> I am working on a patch to fix this issue but I am not sure if there
> is another way.
>
> Best regards.
>
> https://pastebin.ubuntu.com/p/s4h5psqtgZ/
>
>
> unsigned
> rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned
> int num)
> {
> unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num);
>
> /* If buffers removed, allocate mbufs and then put them into alloc_q */
> /* Question, how to test buffers is removed or not?*/
> if (ret)
>     kni_allocate_mbufs(kni);
>
> return ret;
> }
>
> Stephen Hemminger <stephen at networkplumber.org>, 8 May 2023 Pzt, 19:18
> tarihinde şunu yazdı:
>
>> On Mon, 8 May 2023 09:01:41 +0300
>> Yasin CANER <yasinncaner at gmail.com> wrote:
>>
>> > Hello Stephen,
>> >
>> > Thank you for response, it helps me a lot. I understand problem better.
>> >
>> > After reading mbuf library (
>> > https://doc.dpdk.org/guides/prog_guide/mempool_lib.html)  i realized
>> that
>> > 31 units allocation memory slot doesn't return to pool!
>>
>> If receive burst returns 1 mbuf, the other 31 pointers in the array
>> are not valid. They do not point to mbufs.
>>
>> > 1 unit mbuf can be freed via rte_pktmbuf_free so it can back to pool.
>> >
>> > Main problem is that allocation doesn't return to original pool, act as
>> > used. So, after following rte_pktmbuf_free
>> > <
>> http://doc.dpdk.org/api/rte__mbuf_8h.html#a1215458932900b7cd5192326fa4a6902
>> >
>> > function,
>> > i realized that there is 2 function to helps to mbufs back to pool.
>> >
>> > These are rte_mbuf_raw_free
>> > <
>> http://doc.dpdk.org/api/rte__mbuf_8h.html#a9f188d53834978aca01ea101576d7432
>> >
>> >  and rte_pktmbuf_free_seg
>> > <
>> http://doc.dpdk.org/api/rte__mbuf_8h.html#a006ee80357a78fbb9ada2b0432f82f37
>> >.
>> > I will focus on them.
>> >
>> > If there is another suggestion, I will be very pleased.
>> >
>> > Best regards.
>> >
>> > Yasin CANER
>> > Ulak
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mails.dpdk.org/archives/users/attachments/20230511/3c085076/attachment.htm>


More information about the users mailing list