<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi all,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
  Looks like this patch is out there for review for quite some time.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Can somebody review this patch?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
-Harish</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Naga Harish K S V <s.v.naga.harish.k@intel.com><br>
<b>Sent:</b> Thursday, April 14, 2022 11:05 PM<br>
<b>To:</b> ferruh.yigit@xilinx.com <ferruh.yigit@xilinx.com>; Yigit, Ferruh <ferruh.yigit@intel.com><br>
<b>Cc:</b> Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org <dev@dpdk.org><br>
<b>Subject:</b> [PATCH v4] kni: optimize alloc queue release</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The kni alloc queue is filled with physical addresses of mbufs<br>
for kernel consumption. Any unused mbufs in the alloc queue are<br>
freed during shutdown sequence in rte_kni_release.<br>
<br>
In the existing implementation, for freeing one entry of alloc<br>
queue all the objects of the mempool are traversed to find<br>
a match. This process is repeated for all the objects of the<br>
alloc queue which consumes lot of cpu cycles.<br>
<br>
Instead of using mempool object iteration method,use<br>
``rte_mem_iova2virt()`` api to get the virtual address<br>
for the physical addresses of alloc_q objects.<br>
This speeds up the freeing process.<br>
<br>
Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com><br>
---<br>
v2:<br>
* fix checkpatch errors<br>
<br>
v3:<br>
* fix commit message as per review comments<br>
<br>
v4:<br>
* update commit message as per review comments<br>
---<br>
 lib/kni/rte_kni.c | 23 ++++++++---------------<br>
 1 file changed, 8 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c<br>
index 7971c56bb4..f443e5b2fc 100644<br>
--- a/lib/kni/rte_kni.c<br>
+++ b/lib/kni/rte_kni.c<br>
@@ -375,26 +375,19 @@ va2pa_all(struct rte_mbuf *mbuf)<br>
 }<br>
 <br>
 static void<br>
-obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj,<br>
-               unsigned obj_idx __rte_unused)<br>
-{<br>
-       struct rte_mbuf *m = obj;<br>
-       void *mbuf_phys = opaque;<br>
-<br>
-       if (va2pa(m) == mbuf_phys)<br>
-               rte_pktmbuf_free(m);<br>
-}<br>
-<br>
-static void<br>
-kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo)<br>
+kni_free_fifo_phy(struct rte_kni_fifo *fifo)<br>
 {<br>
         void *mbuf_phys;<br>
         int ret;<br>
+       struct rte_mbuf *m;<br>
 <br>
         do {<br>
                 ret = kni_fifo_get(fifo, &mbuf_phys, 1);<br>
-               if (ret)<br>
-                       rte_mempool_obj_iter(mp, obj_free, mbuf_phys);<br>
+               if (ret) {<br>
+                       m = (struct rte_mbuf *)<br>
+                               rte_mem_iova2virt((rte_iova_t)mbuf_phys);<br>
+                       rte_pktmbuf_free(m);<br>
+               }<br>
         } while (ret);<br>
 }<br>
 <br>
@@ -440,7 +433,7 @@ rte_kni_release(struct rte_kni *kni)<br>
         if (kni_fifo_count(kni->rx_q))<br>
                 RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n");<br>
 <br>
-       kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q);<br>
+       kni_free_fifo_phy(kni->alloc_q);<br>
         kni_free_fifo(kni->tx_q);<br>
         kni_free_fifo(kni->free_q);<br>
 <br>
-- <br>
2.23.0<br>
<br>
</div>
</span></font></div>
</body>
</html>