* RE: [PATCH v2] kni: optimize alloc queue release
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 ` [PATCH v3] " Naga Harish K S V
2022-04-14 17:35 ` [PATCH v4] " Naga Harish K S V
2 siblings, 1 reply; 9+ messages in thread
From: Kundapura, Ganapati @ 2022-04-13 10:23 UTC (permalink / raw)
To: Naga Harish K, S V, Yigit, Ferruh; +Cc: Jayatheerthan, Jay, dev
Hi Harish
> -----Original Message-----
> From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> Sent: 13 April 2022 11:19
> To: Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org
> Subject: [PATCH v2] kni: optimize alloc queue release
>
> 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 sppeds up the freeing process.
Nitpick: speeds
>
> Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> ---
> v2:
> * fix checkpatch errors
> ---
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2] kni: optimize alloc queue release
2022-04-13 10:23 ` Kundapura, Ganapati
@ 2022-04-14 10:01 ` Naga Harish K, S V
0 siblings, 0 replies; 9+ messages in thread
From: Naga Harish K, S V @ 2022-04-14 10:01 UTC (permalink / raw)
To: Kundapura, Ganapati, Yigit, Ferruh; +Cc: Jayatheerthan, Jay, dev
Hi Ganapati,
> -----Original Message-----
> From: Kundapura, Ganapati <ganapati.kundapura@intel.com>
> Sent: Wednesday, April 13, 2022 3:54 PM
> To: Naga Harish K, S V <s.v.naga.harish.k@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org
> Subject: RE: [PATCH v2] kni: optimize alloc queue release
>
> Hi Harish
>
> > -----Original Message-----
> > From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> > Sent: 13 April 2022 11:19
> > To: Yigit, Ferruh <ferruh.yigit@intel.com>
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org
> > Subject: [PATCH v2] kni: optimize alloc queue release
> >
> > 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 sppeds up the freeing process.
> Nitpick: speeds
The commit message is updated v3 patch.
> >
> > Signed-off-by: Naga Harish K S V <s.v.naga.harish.k@intel.com>
> > ---
> > v2:
> > * fix checkpatch errors
> > ---
> > 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] kni: optimize alloc queue release
2022-04-13 5:48 ` [PATCH v2] " Naga Harish K S V
2022-04-13 10:23 ` Kundapura, Ganapati
@ 2022-04-13 14:57 ` Naga Harish K S V
2022-04-14 15:20 ` Jayatheerthan, Jay
2022-04-14 17:35 ` [PATCH v4] " Naga Harish K S V
2 siblings, 1 reply; 9+ messages in thread
From: Naga Harish K S V @ 2022-04-13 14:57 UTC (permalink / raw)
To: ferruh.yigit, ferruh.yigit; +Cc: jay.jayatheerthan, dev
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v3] kni: optimize alloc queue release
2022-04-13 14:57 ` [PATCH v3] " Naga Harish K S V
@ 2022-04-14 15:20 ` Jayatheerthan, Jay
2022-04-14 17:38 ` Naga Harish K, S V
0 siblings, 1 reply; 9+ messages in thread
From: Jayatheerthan, Jay @ 2022-04-14 15:20 UTC (permalink / raw)
To: Naga Harish K, S V, ferruh.yigit, Yigit, Ferruh; +Cc: dev
> -----Original Message-----
> From: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> Sent: Wednesday, April 13, 2022 8:27 PM
> To: ferruh.yigit@xilinx.com; Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org
> Subject: [PATCH v3] kni: optimize alloc queue release
>
> the kni alloc queue is filled with physical addresses of mbufs
nitpick: "The" instead of "the".
> 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
nitpick: current and existing are redundant. Can keep one.
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v3] kni: optimize alloc queue release
2022-04-14 15:20 ` Jayatheerthan, Jay
@ 2022-04-14 17:38 ` Naga Harish K, S V
0 siblings, 0 replies; 9+ messages in thread
From: Naga Harish K, S V @ 2022-04-14 17:38 UTC (permalink / raw)
To: Jayatheerthan, Jay, ferruh.yigit, Yigit, Ferruh; +Cc: dev
Hi Jay,
> -----Original Message-----
> From: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>
> Sent: Thursday, April 14, 2022 8:51 PM
> To: Naga Harish K, S V <s.v.naga.harish.k@intel.com>;
> ferruh.yigit@xilinx.com; Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v3] kni: optimize alloc queue release
>
> > -----Original Message-----
> > From: Naga Harish K, S V <s.v.naga.harish.k@intel.com>
> > Sent: Wednesday, April 13, 2022 8:27 PM
> > To: ferruh.yigit@xilinx.com; Yigit, Ferruh <ferruh.yigit@intel.com>
> > Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org
> > Subject: [PATCH v3] kni: optimize alloc queue release
> >
> > the kni alloc queue is filled with physical addresses of mbufs
>
> nitpick: "The" instead of "the".
Updated in v4 patch.
>
> > 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
>
> nitpick: current and existing are redundant. Can keep one.
Updated in v4 patch.
>
> > 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] kni: optimize alloc queue release
2022-04-13 5:48 ` [PATCH v2] " Naga Harish K S V
2022-04-13 10:23 ` Kundapura, Ganapati
2022-04-13 14:57 ` [PATCH v3] " Naga Harish K S V
@ 2022-04-14 17:35 ` Naga Harish K S V
2022-05-31 8:32 ` Naga Harish K, S V
2 siblings, 1 reply; 9+ messages in thread
From: Naga Harish K S V @ 2022-04-14 17:35 UTC (permalink / raw)
To: ferruh.yigit, ferruh.yigit; +Cc: jay.jayatheerthan, dev
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 existing implementation, for freeing one entry of alloc
queue all the objects of the mempool are traversed to find
a match. 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
v4:
* update 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4] kni: optimize alloc queue release
2022-04-14 17:35 ` [PATCH v4] " Naga Harish K S V
@ 2022-05-31 8:32 ` Naga Harish K, S V
0 siblings, 0 replies; 9+ messages in thread
From: Naga Harish K, S V @ 2022-05-31 8:32 UTC (permalink / raw)
To: ferruh.yigit, Yigit, Ferruh, thomas; +Cc: Jayatheerthan, Jay, dev
[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]
Hi all,
Looks like this patch is out there for review for quite some time.
Can somebody review this patch?
-Harish
________________________________
From: Naga Harish K S V <s.v.naga.harish.k@intel.com>
Sent: Thursday, April 14, 2022 11:05 PM
To: ferruh.yigit@xilinx.com <ferruh.yigit@xilinx.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
Cc: Jayatheerthan, Jay <jay.jayatheerthan@intel.com>; dev@dpdk.org <dev@dpdk.org>
Subject: [PATCH v4] kni: optimize alloc queue release
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 existing implementation, for freeing one entry of alloc
queue all the objects of the mempool are traversed to find
a match. 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
v4:
* update 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
[-- Attachment #2: Type: text/html, Size: 6073 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread