<div dir="ltr">Hi Ferruh,<div><br></div><div>In my case, the traffic is not large, so I can't see the impact.<br>I also tested under high load(>2Mpps with 2 DPDK cores and 2 kernel threads)<br>and found no significant difference in performance either.<br>I think the reason should be that it will not<br>run to 'kni_fifo_count(kni->alloc_q) == 0' under high load.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 3, 2023 at 8:47 PM Ferruh Yigit <<a href="mailto:ferruh.yigit@amd.com">ferruh.yigit@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 12/30/2022 4:23 AM, Yangchao Zhou wrote:<br>
> In some scenarios, mbufs returned by rte_kni_rx_burst are not freed<br>
> immediately. So kni_allocate_mbufs may be failed, but we don't know.<br>
> <br>
> Even worse, when alloc_q is completely exhausted, kni_net_tx in<br>
> rte_kni.ko will drop all tx packets. kni_allocate_mbufs is never<br>
> called again, even if the mbufs are eventually freed.<br>
> <br>
> In this patch, we try to allocate mbufs for alloc_q when it is empty.<br>
> <br>
> According to historical experience, the performance bottleneck of KNI<br>
> is offen the usleep_range of kni thread in rte_kni.ko.<br>
> The check of kni_fifo_count is trivial and the cost should be acceptable.<br>
> <br>
<br>
Hi Yangchao,<br>
<br>
Are you observing any performance impact with this change in you use case?<br>
<br>
<br>
> Fixes: 3e12a98fe397 ("kni: optimize Rx burst")<br>
> Cc: <a href="mailto:stable@dpdk.org" target="_blank">stable@dpdk.org</a><br>
> <br>
> Signed-off-by: Yangchao Zhou <<a href="mailto:zhouyates@gmail.com" target="_blank">zhouyates@gmail.com</a>><br>
> ---<br>
>  lib/kni/rte_kni.c | 4 ++--<br>
>  1 file changed, 2 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c<br>
> index 8ab6c47153..bfa6a001ff 100644<br>
> --- a/lib/kni/rte_kni.c<br>
> +++ b/lib/kni/rte_kni.c<br>
> @@ -634,8 +634,8 @@ rte_kni_rx_burst(struct rte_kni *kni, struct rte_mbuf **mbufs, unsigned int num)<br>
>  {<br>
>       unsigned int ret = kni_fifo_get(kni->tx_q, (void **)mbufs, num);<br>
>  <br>
> -     /* If buffers removed, allocate mbufs and then put them into alloc_q */<br>
> -     if (ret)<br>
> +     /* If buffers removed or alloc_q is empty, allocate mbufs and then put them into alloc_q */<br>
> +     if (ret || (kni_fifo_count(kni->alloc_q) == 0))<br>
>               kni_allocate_mbufs(kni);<br>
>  <br>
>       return ret;<br>
<br>
</blockquote></div>