<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 10, 2022 at 12:39 AM Stephen Hemminger <<a href="mailto:stephen@networkplumber.org">stephen@networkplumber.org</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 Wed,  9 Nov 2022 14:04:34 +0800<br>
Yangchao Zhou <<a href="mailto:zhouyates@gmail.com" target="_blank">zhouyates@gmail.com</a>> wrote:<br>
<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 always try to allocate mbufs for alloc_q.<br>
> <br>
> Don't worry about alloc_q being allocated too many mbufs, in fact,<br>
> the old logic will gradually fill up alloc_q.<br>
> Also, the cost of more calls to kni_allocate_mbufs should be acceptable.<br>
> <br>
> Fixes: 3e12a98fe397 ("kni: optimize Rx burst")<br>
> Cc: <a href="mailto:Hemant@freescale.com" target="_blank">Hemant@freescale.com</a><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>
Since fifo_get returning 0 (no buffers) is very common would this<br>
change impact performance.<br></blockquote><div>It does add a little cost, but there is no extra mbuf allocation</div><div>and deallocation.<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If the problem is pool draining might be better to make the pool<br>
bigger.<br></blockquote><div>Yes, using a larger pool can avoid this problem. But this may lead to</div><div>resource wastage and full resource calculation is a challenge for developers</div><div>as it involves to mempool caching mechanism, IP fragment cache,</div><div>ARP cache, NIC txq, other transit queue, etc.<br><br>The mbuf allocation failure may also occur on many NIC drivers,</div><div>but if the mbuf allocation fails, the mbuf is not taken out so that</div><div>it can be recovered after a retry later.<br>KNI currently does not have such a takedown and recovery mechanism.</div><div>It is also possible to consider implementing something similar to</div><div>the NIC driver, but with more changes and other overheads.</div></div></div>