From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
To: ferruh.yigit@xilinx.com, ferruh.yigit@intel.com
Cc: jay.jayatheerthan@intel.com, dev@dpdk.org
Subject: [PATCH v3] kni: optimize alloc queue release
Date: Wed, 13 Apr 2022 09:57:17 -0500 [thread overview]
Message-ID: <20220413145717.3661947-1-s.v.naga.harish.k@intel.com> (raw)
In-Reply-To: <20220413054856.3054752-1-s.v.naga.harish.k@intel.com>
the kni alloc queue is filled with physical addresses of mbufs
for kernel consumption. Any unused mbufs in the alloc queue are
freed during shutdown sequence in rte_kni_release.
In the current existing implementation, for freeing one entry of
alloc queue all the objects of the mempool are traversed. This
process is repeated for all the objects of the alloc queue which
consumes lot of cpu cycles.
Instead of using mempool object iteration method,use
``rte_mem_iova2virt()`` api to get the virtual address
for the physical addresses of alloc_q objects.
This speeds up the freeing process.
Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
---
v2:
* fix checkpatch errors
v3:
* fix commit message as per review comments
---
lib/kni/rte_kni.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/lib/kni/rte_kni.c b/lib/kni/rte_kni.c
index 7971c56bb4..f443e5b2fc 100644
--- a/lib/kni/rte_kni.c
+++ b/lib/kni/rte_kni.c
@@ -375,26 +375,19 @@ va2pa_all(struct rte_mbuf *mbuf)
}
static void
-obj_free(struct rte_mempool *mp __rte_unused, void *opaque, void *obj,
- unsigned obj_idx __rte_unused)
-{
- struct rte_mbuf *m = obj;
- void *mbuf_phys = opaque;
-
- if (va2pa(m) == mbuf_phys)
- rte_pktmbuf_free(m);
-}
-
-static void
-kni_free_fifo_phy(struct rte_mempool *mp, struct rte_kni_fifo *fifo)
+kni_free_fifo_phy(struct rte_kni_fifo *fifo)
{
void *mbuf_phys;
int ret;
+ struct rte_mbuf *m;
do {
ret = kni_fifo_get(fifo, &mbuf_phys, 1);
- if (ret)
- rte_mempool_obj_iter(mp, obj_free, mbuf_phys);
+ if (ret) {
+ m = (struct rte_mbuf *)
+ rte_mem_iova2virt((rte_iova_t)mbuf_phys);
+ rte_pktmbuf_free(m);
+ }
} while (ret);
}
@@ -440,7 +433,7 @@ rte_kni_release(struct rte_kni *kni)
if (kni_fifo_count(kni->rx_q))
RTE_LOG(ERR, KNI, "Fail to free all Rx-q items\n");
- kni_free_fifo_phy(kni->pktmbuf_pool, kni->alloc_q);
+ kni_free_fifo_phy(kni->alloc_q);
kni_free_fifo(kni->tx_q);
kni_free_fifo(kni->free_q);
--
2.23.0
next prev parent reply other threads:[~2022-04-13 14:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 5:40 [PATCH] " Naga Harish K S V
2022-04-13 5:48 ` [PATCH v2] " Naga Harish K S V
2022-04-13 10:23 ` Kundapura, Ganapati
2022-04-14 10:01 ` Naga Harish K, S V
2022-04-13 14:57 ` Naga Harish K S V [this message]
2022-04-14 15:20 ` [PATCH v3] " Jayatheerthan, Jay
2022-04-14 17:38 ` Naga Harish K, S V
2022-04-14 17:35 ` [PATCH v4] " Naga Harish K S V
2022-05-31 8:32 ` Naga Harish K, S V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220413145717.3661947-1-s.v.naga.harish.k@intel.com \
--to=s.v.naga.harish.k@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=ferruh.yigit@xilinx.com \
--cc=jay.jayatheerthan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).