DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH v1 0/2] wrong pointer passed of ring
@ 2020-07-29  6:31 Feifei Wang
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param Feifei Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Feifei Wang @ 2020-07-29  6:31 UTC (permalink / raw)
  Cc: dev, nd, Feifei Wang

Fix wrong pointer passed problems when using rte_ring_[sp|mp]enqueue
APIs to enqueue one element into the ring.

Feifei Wang (2):
  ring: fix the misdescription of the param
  test/ring: fix wrong parameter passed to the enqueue APIs

 app/test/test_ring.h       | 6 +++---
 lib/librte_ring/rte_ring.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-29  6:31 [dpdk-dev] [PATCH v1 0/2] wrong pointer passed of ring Feifei Wang
@ 2020-07-29  6:31 ` Feifei Wang
  2020-07-29 15:59   ` David Marchand
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs Feifei Wang
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
  2 siblings, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-29  6:31 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev; +Cc: dev, nd, Feifei Wang, stable

When enqueue one element to the ring, the param "obj" should be the
object to be added into the ring. The object is of type void*.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/librte_ring/rte_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index da17ed6d7..418536b61 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
  * @param r
  *   A pointer to the ring structure.
  * @param obj
- *   A pointer to the object to be added.
+ *   A pointer (object) to be added.
  * @return
  *   - 0: Success; objects enqueued.
  *   - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
@@ -293,7 +293,7 @@ rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
  * @param r
  *   A pointer to the ring structure.
  * @param obj
- *   A pointer to the object to be added.
+ *   A pointer (object) to be added.
  * @return
  *   - 0: Success; objects enqueued.
  *   - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
@@ -314,7 +314,7 @@ rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
  * @param r
  *   A pointer to the ring structure.
  * @param obj
- *   A pointer to the object to be added.
+ *   A pointer (object) to be added.
  * @return
  *   - 0: Success; objects enqueued.
  *   - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29  6:31 [dpdk-dev] [PATCH v1 0/2] wrong pointer passed of ring Feifei Wang
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param Feifei Wang
@ 2020-07-29  6:31 ` Feifei Wang
  2020-07-29 13:48   ` David Marchand
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
  2 siblings, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-29  6:31 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz
  Cc: dev, nd, Feifei Wang, stable

When enqueue one element (object of type void*) to ring in the
performance test, a pointer (the object to be enqueued) should be
passed to rte_ring_[sp|mp]enqueue APIs, not the pointer to a table
of void *pointers (objects).

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test/test_ring.h b/app/test/test_ring.h
index aa6ae67ca..d4b15af7c 100644
--- a/app/test/test_ring.h
+++ b/app/test/test_ring.h
@@ -50,11 +50,11 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 	if ((esize) == -1)
 		switch (api_type) {
 		case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):
-			return rte_ring_enqueue(r, obj);
+			return rte_ring_enqueue(r, *obj);
 		case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):
-			return rte_ring_sp_enqueue(r, obj);
+			return rte_ring_sp_enqueue(r, *obj);
 		case (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):
-			return rte_ring_mp_enqueue(r, obj);
+			return rte_ring_mp_enqueue(r, *obj);
 		case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):
 			return rte_ring_enqueue_bulk(r, obj, n, NULL);
 		case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs Feifei Wang
@ 2020-07-29 13:48   ` David Marchand
  2020-07-29 14:16     ` [dpdk-dev] 回复: " Feifei Wang
  0 siblings, 1 reply; 20+ messages in thread
From: David Marchand @ 2020-07-29 13:48 UTC (permalink / raw)
  To: Feifei Wang
  Cc: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz,
	dev, nd, dpdk stable

Hello Feifei,

On Wed, Jul 29, 2020 at 8:32 AM Feifei Wang <feifei.wang2@arm.com> wrote:
>
> When enqueue one element (object of type void*) to ring in the
> performance test, a pointer (the object to be enqueued) should be
> passed to rte_ring_[sp|mp]enqueue APIs, not the pointer to a table
> of void *pointers (objects).

Good catch.
Are we missing a check in the UT so that dequeued object is what had
been enqueued?


>
> Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
> Cc: honnappa.nagarahalli@arm.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>  app/test/test_ring.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/app/test/test_ring.h b/app/test/test_ring.h
> index aa6ae67ca..d4b15af7c 100644
> --- a/app/test/test_ring.h
> +++ b/app/test/test_ring.h
> @@ -50,11 +50,11 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
>         if ((esize) == -1)
>                 switch (api_type) {
>                 case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):
> -                       return rte_ring_enqueue(r, obj);
> +                       return rte_ring_enqueue(r, *obj);
>                 case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):
> -                       return rte_ring_sp_enqueue(r, obj);
> +                       return rte_ring_sp_enqueue(r, *obj);
>                 case (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):
> -                       return rte_ring_mp_enqueue(r, obj);
> +                       return rte_ring_mp_enqueue(r, *obj);
>                 case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):
>                         return rte_ring_enqueue_bulk(r, obj, n, NULL);
>                 case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):
> --
> 2.17.1
>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] 回复:  [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29 13:48   ` David Marchand
@ 2020-07-29 14:16     ` " Feifei Wang
  2020-07-29 14:21       ` [dpdk-dev] " David Marchand
  0 siblings, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-29 14:16 UTC (permalink / raw)
  To: David Marchand
  Cc: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz,
	dev, nd, dpdk stable, nd

Hi, David

> -----邮件原件-----
> 发件人: David Marchand <david.marchand@redhat.com>
> 发送时间: 2020年7月29日 21:48
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>
> 抄送: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Konstantin
> Ananyev <konstantin.ananyev@intel.com>; Gavin Hu <Gavin.Hu@arm.com>;
> Olivier Matz <olivier.matz@6wind.com>; dev <dev@dpdk.org>; nd
> <nd@arm.com>; dpdk stable <stable@dpdk.org>
> 主题: Re: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the
> enqueue APIs
> 
> Hello Feifei,
> 
> On Wed, Jul 29, 2020 at 8:32 AM Feifei Wang <feifei.wang2@arm.com>
> wrote:
> >
> > When enqueue one element (object of type void*) to ring in the
> > performance test, a pointer (the object to be enqueued) should be
> > passed to rte_ring_[sp|mp]enqueue APIs, not the pointer to a table of
> > void *pointers (objects).
> 
> Good catch.
Thanks very much.
> Are we missing a check in the UT so that dequeued object is what had been
> enqueued?
> 
>  
Dequeue is not necessary to change because the param defined in rte_ring_dequeue
is different from that in rte_ring_enqueue:
rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a pointer (object) to be added in the ring
rte_ring_dequeue(struct rte_ring *r, void **obj_p): obj_p is a pointer to a void * pointer
(object) that will be filled.
> >
> > Fixes: a9fe152363e2 ("test/ring: add custom element size functional
> > tests")
> > Cc: honnappa.nagarahalli@arm.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> >  app/test/test_ring.h | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/app/test/test_ring.h b/app/test/test_ring.h index
> > aa6ae67ca..d4b15af7c 100644
> > --- a/app/test/test_ring.h
> > +++ b/app/test/test_ring.h
> > @@ -50,11 +50,11 @@ test_ring_enqueue(struct rte_ring *r, void **obj,
> int esize, unsigned int n,
> >         if ((esize) == -1)
> >                 switch (api_type) {
> >                 case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):
> > -                       return rte_ring_enqueue(r, obj);
> > +                       return rte_ring_enqueue(r, *obj);
> >                 case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):
> > -                       return rte_ring_sp_enqueue(r, obj);
> > +                       return rte_ring_sp_enqueue(r, *obj);
> >                 case (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):
> > -                       return rte_ring_mp_enqueue(r, obj);
> > +                       return rte_ring_mp_enqueue(r, *obj);
> >                 case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):
> >                         return rte_ring_enqueue_bulk(r, obj, n, NULL);
> >                 case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):
> > --
> > 2.17.1
> >
> 
> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29 14:16     ` [dpdk-dev] 回复: " Feifei Wang
@ 2020-07-29 14:21       ` " David Marchand
  2020-07-29 15:03         ` [dpdk-dev] 回复: " Feifei Wang
  0 siblings, 1 reply; 20+ messages in thread
From: David Marchand @ 2020-07-29 14:21 UTC (permalink / raw)
  To: Feifei Wang
  Cc: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz,
	dev, nd, dpdk stable

On Wed, Jul 29, 2020 at 4:16 PM Feifei Wang <Feifei.Wang2@arm.com> wrote:
> > Are we missing a check in the UT so that dequeued object is what had been
> > enqueued?
> >
> >
> Dequeue is not necessary to change because the param defined in rte_ring_dequeue
> is different from that in rte_ring_enqueue:
> rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a pointer (object) to be added in the ring
> rte_ring_dequeue(struct rte_ring *r, void **obj_p): obj_p is a pointer to a void * pointer
> (object) that will be filled.

That I get it.

What I meant is that the test enqueues an object in a ring until it is
full [1], then dequeues all the ring [2].
1: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n814
2: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n825

If the test had checked that dequeued objects are the right one, we
would have caught it.

But on the other hand, maybe another part of the functionnal ring
tests already check this and we only need to fix this issue here.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] 回复:  [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29 14:21       ` [dpdk-dev] " David Marchand
@ 2020-07-29 15:03         ` " Feifei Wang
  2020-07-29 21:24           ` [dpdk-dev] " Honnappa Nagarahalli
  0 siblings, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-29 15:03 UTC (permalink / raw)
  To: David Marchand
  Cc: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz,
	dev, nd, dpdk stable, nd



> -----邮件原件-----
> 发件人: David Marchand <david.marchand@redhat.com>
> 发送时间: 2020年7月29日 22:21
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>
> 抄送: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; Konstantin
> Ananyev <konstantin.ananyev@intel.com>; Gavin Hu <Gavin.Hu@arm.com>;
> Olivier Matz <olivier.matz@6wind.com>; dev <dev@dpdk.org>; nd
> <nd@arm.com>; dpdk stable <stable@dpdk.org>
> 主题: Re: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the
> enqueue APIs
> 
> On Wed, Jul 29, 2020 at 4:16 PM Feifei Wang <Feifei.Wang2@arm.com>
> wrote:
> > > Are we missing a check in the UT so that dequeued object is what had
> > > been enqueued?
> > >
> > >
> > Dequeue is not necessary to change because the param defined in
> > rte_ring_dequeue is different from that in rte_ring_enqueue:
> > rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a pointer
> > (object) to be added in the ring rte_ring_dequeue(struct rte_ring *r,
> > void **obj_p): obj_p is a pointer to a void * pointer
> > (object) that will be filled.
> 
> That I get it.
> 
> What I meant is that the test enqueues an object in a ring until it is full [1],
> then dequeues all the ring [2].
> 1: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n814
> 2: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n825
> 
> If the test had checked that dequeued objects are the right one, we would
> have caught it.
> 
> But on the other hand, maybe another part of the functionnal ring tests
> already check this and we only need to fix this issue here.

Sorry I just misunderstood you.
1. Actually, for the APIs of test_ring.h, we lack a test to check whether the
value of object enqueued into the ring matches that dequeued from the ring.
But it is mainly used to measure the length of time from enqueue to dequeue.
So I'm not sure it is necessary.
2. For the APIs of rte_ring.h, some tests can be used to test whether the
value of object enqueued into the ring matches that dequeued from the ring.
For example:
$table_autotest
$mbuf_autotest
> 
> 
> --
> David Marchand

--
Feifei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param Feifei Wang
@ 2020-07-29 15:59   ` David Marchand
  2020-07-29 16:24     ` Ananyev, Konstantin
  2020-07-30 10:16     ` [dpdk-dev] 回复: " Feifei Wang
  0 siblings, 2 replies; 20+ messages in thread
From: David Marchand @ 2020-07-29 15:59 UTC (permalink / raw)
  To: Feifei Wang, Ananyev, Konstantin, Honnappa Nagarahalli, Olivier Matz
  Cc: dev, nd, dpdk stable, Thomas Monjalon

On Wed, Jul 29, 2020 at 8:31 AM Feifei Wang <feifei.wang2@arm.com> wrote:
>
> When enqueue one element to the ring, the param "obj" should be the
> object to be added into the ring. The object is of type void*.

I understand void * as a pointer to an object you don't know the type of.
I would keep the current description.

Honnappa, Konstantin, Olivier ?

>
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
>
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>  lib/librte_ring/rte_ring.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> index da17ed6d7..418536b61 100644
> --- a/lib/librte_ring/rte_ring.h
> +++ b/lib/librte_ring/rte_ring.h
> @@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
>   * @param r
>   *   A pointer to the ring structure.
>   * @param obj
> - *   A pointer to the object to be added.
> + *   A pointer (object) to be added.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-29 15:59   ` David Marchand
@ 2020-07-29 16:24     ` Ananyev, Konstantin
  2020-07-29 19:34       ` Honnappa Nagarahalli
  2020-07-30 10:16     ` [dpdk-dev] 回复: " Feifei Wang
  1 sibling, 1 reply; 20+ messages in thread
From: Ananyev, Konstantin @ 2020-07-29 16:24 UTC (permalink / raw)
  To: David Marchand, Feifei Wang, Honnappa Nagarahalli, Olivier Matz
  Cc: dev, nd, dpdk stable, Thomas Monjalon

> >
> > When enqueue one element to the ring, the param "obj" should be the
> > object to be added into the ring. The object is of type void*.
> 
> I understand void * as a pointer to an object you don't know the type of.
> I would keep the current description.
> 
> Honnappa, Konstantin, Olivier ?

I think current one is a bit cleaner.
Konstantin


> 
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> >  lib/librte_ring/rte_ring.h | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > index da17ed6d7..418536b61 100644
> > --- a/lib/librte_ring/rte_ring.h
> > +++ b/lib/librte_ring/rte_ring.h
> > @@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
> >   * @param r
> >   *   A pointer to the ring structure.
> >   * @param obj
> > - *   A pointer to the object to be added.
> > + *   A pointer (object) to be added.
> 
> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-29 16:24     ` Ananyev, Konstantin
@ 2020-07-29 19:34       ` Honnappa Nagarahalli
  0 siblings, 0 replies; 20+ messages in thread
From: Honnappa Nagarahalli @ 2020-07-29 19:34 UTC (permalink / raw)
  To: Ananyev, Konstantin, David Marchand, Feifei Wang, Olivier Matz
  Cc: dev, nd, dpdk stable, thomas, Honnappa Nagarahalli, nd

<snip>

> Subject: RE: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the
> param
> 
> > >
> > > When enqueue one element to the ring, the param "obj" should be the
> > > object to be added into the ring. The object is of type void*.
> >
> > I understand void * as a pointer to an object you don't know the type of.
> > I would keep the current description.
> >
> > Honnappa, Konstantin, Olivier ?
> 
> I think current one is a bit cleaner.
+1, the existing documentation is fine.

> Konstantin
> 
> 
> >
> > >
> > > Fixes: af75078fece3 ("first public release")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > > ---
> > >  lib/librte_ring/rte_ring.h | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > > index da17ed6d7..418536b61 100644
> > > --- a/lib/librte_ring/rte_ring.h
> > > +++ b/lib/librte_ring/rte_ring.h
> > > @@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void *
> const *obj_table,
> > >   * @param r
> > >   *   A pointer to the ring structure.
> > >   * @param obj
> > > - *   A pointer to the object to be added.
> > > + *   A pointer (object) to be added.
> >
> >
> > --
> > David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29 15:03         ` [dpdk-dev] 回复: " Feifei Wang
@ 2020-07-29 21:24           ` " Honnappa Nagarahalli
  2020-07-30 10:28             ` [dpdk-dev] 回复: " Feifei Wang
  0 siblings, 1 reply; 20+ messages in thread
From: Honnappa Nagarahalli @ 2020-07-29 21:24 UTC (permalink / raw)
  To: Feifei Wang, David Marchand
  Cc: Konstantin Ananyev, Gavin Hu, Olivier Matz, dev, nd, dpdk stable,
	Honnappa Nagarahalli, nd

<snip>

> >
> > On Wed, Jul 29, 2020 at 4:16 PM Feifei Wang <Feifei.Wang2@arm.com>
> > wrote:
> > > > Are we missing a check in the UT so that dequeued object is what
> > > > had been enqueued?
Yes, missing for single element enqueue/dequeue

> > > >
> > > >
> > > Dequeue is not necessary to change because the param defined in
> > > rte_ring_dequeue is different from that in rte_ring_enqueue:
> > > rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a pointer
> > > (object) to be added in the ring rte_ring_dequeue(struct rte_ring
> > > *r, void **obj_p): obj_p is a pointer to a void * pointer
> > > (object) that will be filled.
> >
> > That I get it.
> >
> > What I meant is that the test enqueues an object in a ring until it is
> > full [1], then dequeues all the ring [2].
> > 1: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n814
> > 2: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n825
> >
> > If the test had checked that dequeued objects are the right one, we
> > would have caught it.
> >
> > But on the other hand, maybe another part of the functionnal ring
> > tests already check this and we only need to fix this issue here.
> 
> Sorry I just misunderstood you.
> 1. Actually, for the APIs of test_ring.h, we lack a test to check whether the
> value of object enqueued into the ring matches that dequeued from the ring.
> But it is mainly used to measure the length of time from enqueue to dequeue.
> So I'm not sure it is necessary.
> 2. For the APIs of rte_ring.h, some tests can be used to test whether the value
> of object enqueued into the ring matches that dequeued from the ring.
> For example:
> $table_autotest
> $mbuf_autotest
The dequeued objects are checked against the enqueued objects for the bulk and burst APIs. Look at tests test_ring_burst_bulk_tests1..4. 'memcmp' is used to compare the enqueued objects against the dequeued ones.
Similar comparison can be added in test_ring_basic_ex, test_ring_with_exact_size functions.

> >
> >
> > --
> > David Marchand
> 
> --
> Feifei
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] 回复:  [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-29 15:59   ` David Marchand
  2020-07-29 16:24     ` Ananyev, Konstantin
@ 2020-07-30 10:16     ` " Feifei Wang
  2020-07-31  5:26       ` [dpdk-dev] " Honnappa Nagarahalli
  1 sibling, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-30 10:16 UTC (permalink / raw)
  To: David Marchand, Ananyev, Konstantin, Honnappa Nagarahalli, Olivier Matz
  Cc: dev, nd, dpdk stable, thomas, nd

Hi, David, Konstantin and Honnappa

> -----邮件原件-----
> 发件人: David Marchand <david.marchand@redhat.com>
> 发送时间: 2020年7月30日 0:00
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Olivier Matz <olivier.matz@6wind.com>
> 抄送: dev <dev@dpdk.org>; nd <nd@arm.com>; dpdk stable
> <stable@dpdk.org>; thomas@monjalon.net
> 主题: Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
> 
> On Wed, Jul 29, 2020 at 8:31 AM Feifei Wang <feifei.wang2@arm.com>
> wrote:
> >
> > When enqueue one element to the ring, the param "obj" should be the
> > object to be added into the ring. The object is of type void*.
> 
> I understand void * as a pointer to an object you don't know the type of.
> I would keep the current description.
> 
Sorry for my commit message cannot express my view clearly. 
Following is my supplementary explanation of this:

First,  the APIs to be changed are:
1. rte_ring_mp_enqueue
2. rte_ring_sp_enqueue
3. rte_ring_enqueue

Second, Let's use an example to explain this:
1. We call API in form: rte_ring_enqueue(r, obj).
2. Current function header indicates that we will have ring[idx] = *obj.
3. However, this is not the case, what we eventually have is: ring[idx] = obj.

So I think the current function header is misleading or
maybe the implementation of above three functions need to be changed.

> Honnappa, Konstantin, Olivier ?
> 
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > ---
> >  lib/librte_ring/rte_ring.h | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > index da17ed6d7..418536b61 100644
> > --- a/lib/librte_ring/rte_ring.h
> > +++ b/lib/librte_ring/rte_ring.h
> > @@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void *
> const *obj_table,
> >   * @param r
> >   *   A pointer to the ring structure.
> >   * @param obj
> > - *   A pointer to the object to be added.
> > + *   A pointer (object) to be added.
> 
> 
> --
> David Marchand


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] 回复:  [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-29 21:24           ` [dpdk-dev] " Honnappa Nagarahalli
@ 2020-07-30 10:28             ` " Feifei Wang
  2020-07-31  6:25               ` Feifei Wang
  0 siblings, 1 reply; 20+ messages in thread
From: Feifei Wang @ 2020-07-30 10:28 UTC (permalink / raw)
  To: Honnappa Nagarahalli, David Marchand
  Cc: Konstantin Ananyev, Gavin Hu, Olivier Matz, dev, nd, dpdk stable, nd, nd



> -----邮件原件-----
> 发件人: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> 发送时间: 2020年7月30日 5:24
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; David Marchand
> <david.marchand@redhat.com>
> 抄送: Konstantin Ananyev <konstantin.ananyev@intel.com>; Gavin Hu
> <Gavin.Hu@arm.com>; Olivier Matz <olivier.matz@6wind.com>; dev
> <dev@dpdk.org>; nd <nd@arm.com>; dpdk stable <stable@dpdk.org>;
> Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> 主题: RE: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the
> enqueue APIs
> 
> <snip>
> 
> > >
> > > On Wed, Jul 29, 2020 at 4:16 PM Feifei Wang <Feifei.Wang2@arm.com>
> > > wrote:
> > > > > Are we missing a check in the UT so that dequeued object is what
> > > > > had been enqueued?
> Yes, missing for single element enqueue/dequeue
> 
> > > > >
> > > > >
> > > > Dequeue is not necessary to change because the param defined in
> > > > rte_ring_dequeue is different from that in rte_ring_enqueue:
> > > > rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a pointer
> > > > (object) to be added in the ring rte_ring_dequeue(struct rte_ring
> > > > *r, void **obj_p): obj_p is a pointer to a void * pointer
> > > > (object) that will be filled.
> > >
> > > That I get it.
> > >
> > > What I meant is that the test enqueues an object in a ring until it
> > > is full [1], then dequeues all the ring [2].
> > > 1: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n814
> > > 2: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n825
> > >
> > > If the test had checked that dequeued objects are the right one, we
> > > would have caught it.
> > >
> > > But on the other hand, maybe another part of the functionnal ring
> > > tests already check this and we only need to fix this issue here.
> >
> > Sorry I just misunderstood you.
> > 1. Actually, for the APIs of test_ring.h, we lack a test to check
> > whether the value of object enqueued into the ring matches that dequeued
> from the ring.
> > But it is mainly used to measure the length of time from enqueue to
> dequeue.
> > So I'm not sure it is necessary.
> > 2. For the APIs of rte_ring.h, some tests can be used to test whether
> > the value of object enqueued into the ring matches that dequeued from the
> ring.
> > For example:
> > $table_autotest
> > $mbuf_autotest
> The dequeued objects are checked against the enqueued objects for the bulk
> and burst APIs. Look at tests test_ring_burst_bulk_tests1..4. 'memcmp' is used
> to compare the enqueued objects against the dequeued ones.
> Similar comparison can be added in test_ring_basic_ex,
> test_ring_with_exact_size functions.
Thank you for bringing that up.
> 
> > >
> > >
> > > --
> > > David Marchand
> >
> > --
> > Feifei
> >


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param
  2020-07-30 10:16     ` [dpdk-dev] 回复: " Feifei Wang
@ 2020-07-31  5:26       ` " Honnappa Nagarahalli
  0 siblings, 0 replies; 20+ messages in thread
From: Honnappa Nagarahalli @ 2020-07-31  5:26 UTC (permalink / raw)
  To: Feifei Wang, David Marchand, Ananyev, Konstantin, Olivier Matz
  Cc: dev, nd, dpdk stable, thomas, Honnappa Nagarahalli, nd

<snip>

> > 主题: Re: [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the
> > param
> >
> > On Wed, Jul 29, 2020 at 8:31 AM Feifei Wang <feifei.wang2@arm.com>
> > wrote:
> > >
> > > When enqueue one element to the ring, the param "obj" should be the
> > > object to be added into the ring. The object is of type void*.
> >
> > I understand void * as a pointer to an object you don't know the type of.
> > I would keep the current description.
> >
> Sorry for my commit message cannot express my view clearly.
> Following is my supplementary explanation of this:
> 
> First,  the APIs to be changed are:
> 1. rte_ring_mp_enqueue
> 2. rte_ring_sp_enqueue
> 3. rte_ring_enqueue
> 
> Second, Let's use an example to explain this:
> 1. We call API in form: rte_ring_enqueue(r, obj).
> 2. Current function header indicates that we will have ring[idx] = *obj.
When you say function header, I am assuming you are talking about the documentation. IMO, the current documentation does not convey any details of the implementation. It is talking about what is expected from the user.

> 3. However, this is not the case, what we eventually have is: ring[idx] = obj.
> 
> So I think the current function header is misleading or maybe the
> implementation of above three functions need to be changed.
> 
> > Honnappa, Konstantin, Olivier ?
> >
> > >
> > > Fixes: af75078fece3 ("first public release")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > > ---
> > >  lib/librte_ring/rte_ring.h | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
> > > index da17ed6d7..418536b61 100644
> > > --- a/lib/librte_ring/rte_ring.h
> > > +++ b/lib/librte_ring/rte_ring.h
> > > @@ -276,7 +276,7 @@ rte_ring_enqueue_bulk(struct rte_ring *r, void *
> > const *obj_table,
> > >   * @param r
> > >   *   A pointer to the ring structure.
> > >   * @param obj
> > > - *   A pointer to the object to be added.
> > > + *   A pointer (object) to be added.
> >
> >
> > --
> > David Marchand
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] 回复:  [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs
  2020-07-30 10:28             ` [dpdk-dev] 回复: " Feifei Wang
@ 2020-07-31  6:25               ` Feifei Wang
  0 siblings, 0 replies; 20+ messages in thread
From: Feifei Wang @ 2020-07-31  6:25 UTC (permalink / raw)
  To: Honnappa Nagarahalli, David Marchand
  Cc: Konstantin Ananyev, Gavin Hu, Olivier Matz, dev, nd, dpdk stable,
	nd, nd, nd



> -----邮件原件-----
> 发件人: Feifei Wang
> 发送时间: 2020年7月30日 18:29
> 收件人: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; David
> Marchand <david.marchand@redhat.com>
> 抄送: Konstantin Ananyev <konstantin.ananyev@intel.com>; Gavin Hu
> <Gavin.Hu@arm.com>; Olivier Matz <olivier.matz@6wind.com>; dev
> <dev@dpdk.org>; nd <nd@arm.com>; dpdk stable <stable@dpdk.org>; nd
> <nd@arm.com>; nd <nd@arm.com>
> 主题: 回复: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to
> the enqueue APIs
> 
> 
> 
> > -----邮件原件-----
> > 发件人: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> > 发送时间: 2020年7月30日 5:24
> > 收件人: Feifei Wang <Feifei.Wang2@arm.com>; David Marchand
> > <david.marchand@redhat.com>
> > 抄送: Konstantin Ananyev <konstantin.ananyev@intel.com>; Gavin Hu
> > <Gavin.Hu@arm.com>; Olivier Matz <olivier.matz@6wind.com>; dev
> > <dev@dpdk.org>; nd <nd@arm.com>; dpdk stable <stable@dpdk.org>;
> > Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; nd
> <nd@arm.com>
> > 主题: RE: [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to
> > the enqueue APIs
> >
> > <snip>
> >
> > > >
> > > > On Wed, Jul 29, 2020 at 4:16 PM Feifei Wang <Feifei.Wang2@arm.com>
> > > > wrote:
> > > > > > Are we missing a check in the UT so that dequeued object is
> > > > > > what had been enqueued?
> > Yes, missing for single element enqueue/dequeue
> >
> > > > > >
> > > > > >
> > > > > Dequeue is not necessary to change because the param defined in
> > > > > rte_ring_dequeue is different from that in rte_ring_enqueue:
> > > > > rte_ring_enqueue(struct rte_ring *r, void *obj): obj is a
> > > > > pointer
> > > > > (object) to be added in the ring rte_ring_dequeue(struct
> > > > > rte_ring *r, void **obj_p): obj_p is a pointer to a void *
> > > > > pointer
> > > > > (object) that will be filled.
> > > >
> > > > That I get it.
> > > >
> > > > What I meant is that the test enqueues an object in a ring until
> > > > it is full [1], then dequeues all the ring [2].
> > > > 1: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n814
> > > > 2: https://git.dpdk.org/dpdk/tree/app/test/test_ring.c#n825
> > > >
> > > > If the test had checked that dequeued objects are the right one,
> > > > we would have caught it.
> > > >
> > > > But on the other hand, maybe another part of the functionnal ring
> > > > tests already check this and we only need to fix this issue here.
> > >
> > > Sorry I just misunderstood you.
> > > 1. Actually, for the APIs of test_ring.h, we lack a test to check
> > > whether the value of object enqueued into the ring matches that
> > > dequeued
> > from the ring.
> > > But it is mainly used to measure the length of time from enqueue to
> > dequeue.
> > > So I'm not sure it is necessary.
> > > 2. For the APIs of rte_ring.h, some tests can be used to test
> > > whether the value of object enqueued into the ring matches that
> > > dequeued from the
> > ring.
> > > For example:
> > > $table_autotest
> > > $mbuf_autotest
> > The dequeued objects are checked against the enqueued objects for the
> > bulk and burst APIs. Look at tests test_ring_burst_bulk_tests1..4.
> > 'memcmp' is used to compare the enqueued objects against the dequeued
> ones.
> > Similar comparison can be added in test_ring_basic_ex,
> > test_ring_with_exact_size functions.
> Thank you for bringing that up.
Next, I will adding the test to check the value of dequeue against enqueue in
test_ring_basic_ex,  test_ring_with_exact_size functions. Furthermore, I will pack
it and the current patch together and upload the new version to the community. 
> >
> > > >
> > > >
> > > > --
> > > > David Marchand
> > >
> > > --
> > > Feifei
> > >


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check
  2020-07-29  6:31 [dpdk-dev] [PATCH v1 0/2] wrong pointer passed of ring Feifei Wang
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param Feifei Wang
  2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs Feifei Wang
@ 2020-08-05  6:14 ` Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 1/4] test/ring: fix wrong parameter passed to the enqueue APIs Feifei Wang
                     ` (3 more replies)
  2 siblings, 4 replies; 20+ messages in thread
From: Feifei Wang @ 2020-08-05  6:14 UTC (permalink / raw)
  Cc: dev, nd, Feifei Wang

Fix wrong pointer passed problems when using test_ring_enqueue APIs to
enqueue one element into the ring.

Furthermore, add check to validate the dequeued objects in test_ring.c
when calling test_ring_enqueue APIs.

v2:
1. add check to validate the dequeued objects in test_ring.c and fix
some bugs of it. (David/Honnappa)
2. remove the patch to change the description for the param of
rte_ring_[sp/mp]_enqueue APIs. (David/Konstantin/Honnappa)

Feifei Wang (4):
  test/ring: fix wrong parameter passed to the enqueue APIs
  test/ring: fix wrong size used in memcmp
  test/ring: fix the wrong number of enq/deq elements
  test/ring: add check to validate the dequeued objects

 app/test/test_ring.c | 180 +++++++++++++++++++++++++++++++------------
 app/test/test_ring.h |   6 +-
 2 files changed, 135 insertions(+), 51 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 1/4] test/ring: fix wrong parameter passed to the enqueue APIs
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
@ 2020-08-05  6:14   ` Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 2/4] test/ring: fix wrong size used in memcmp Feifei Wang
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 20+ messages in thread
From: Feifei Wang @ 2020-08-05  6:14 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev, Olivier Matz, Gavin Hu
  Cc: dev, nd, Feifei Wang, stable

When enqueue one element to ring in the performance test, a pointer
should be passed to rte_ring_[sp|mp]enqueue APIs, not the pointer
to a table of void *pointers.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 app/test/test_ring.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/test/test_ring.h b/app/test/test_ring.h
index aa6ae67ca..d4b15af7c 100644
--- a/app/test/test_ring.h
+++ b/app/test/test_ring.h
@@ -50,11 +50,11 @@ test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,
 	if ((esize) == -1)
 		switch (api_type) {
 		case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):
-			return rte_ring_enqueue(r, obj);
+			return rte_ring_enqueue(r, *obj);
 		case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):
-			return rte_ring_sp_enqueue(r, obj);
+			return rte_ring_sp_enqueue(r, *obj);
 		case (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):
-			return rte_ring_mp_enqueue(r, obj);
+			return rte_ring_mp_enqueue(r, *obj);
 		case (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):
 			return rte_ring_enqueue_bulk(r, obj, n, NULL);
 		case (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 2/4] test/ring: fix wrong size used in memcmp
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 1/4] test/ring: fix wrong parameter passed to the enqueue APIs Feifei Wang
@ 2020-08-05  6:14   ` Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 4/4] test/ring: add check to validate the dequeued objects Feifei Wang
  3 siblings, 0 replies; 20+ messages in thread
From: Feifei Wang @ 2020-08-05  6:14 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev, Gavin Hu, Olivier Matz
  Cc: dev, nd, Feifei Wang, stable

When using memcmp function to check data, the third param should be the
size of all elements, rather than the number of the elements.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 app/test/test_ring.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 0ae97d341..c508a13a9 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -444,7 +444,12 @@ test_ring_burst_bulk_tests1(unsigned int test_idx)
 			TEST_RING_VERIFY(rte_ring_empty(r));
 
 			/* check data */
-			TEST_RING_VERIFY(memcmp(src, dst, rsz) == 0);
+			if (esize[i] == -1) {
+				TEST_RING_VERIFY(memcmp(src, dst,
+					rsz * sizeof(void *)) == 0);
+			} else
+				TEST_RING_VERIFY(memcmp(src, dst,
+					rsz * esize[i]) == 0);
 		}
 
 		/* Free memory before test completed */
@@ -538,9 +543,11 @@ test_ring_burst_bulk_tests2(unsigned int test_idx)
 		cur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK);
 
 		/* check data */
-		if (memcmp(src, dst, cur_dst - dst)) {
-			rte_hexdump(stdout, "src", src, cur_src - src);
-			rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
 			printf("data after dequeue is not the same\n");
 			goto fail;
 		}
@@ -614,9 +621,11 @@ test_ring_burst_bulk_tests3(unsigned int test_idx)
 		}
 
 		/* check data */
-		if (memcmp(src, dst, cur_dst - dst)) {
-			rte_hexdump(stdout, "src", src, cur_src - src);
-			rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
 			printf("data after dequeue is not the same\n");
 			goto fail;
 		}
@@ -747,9 +756,11 @@ test_ring_burst_bulk_tests4(unsigned int test_idx)
 			goto fail;
 
 		/* check data */
-		if (memcmp(src, dst, cur_dst - dst)) {
-			rte_hexdump(stdout, "src", src, cur_src - src);
-			rte_hexdump(stdout, "dst", dst, cur_dst - dst);
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
 			printf("data after dequeue is not the same\n");
 			goto fail;
 		}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 1/4] test/ring: fix wrong parameter passed to the enqueue APIs Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 2/4] test/ring: fix wrong size used in memcmp Feifei Wang
@ 2020-08-05  6:14   ` Feifei Wang
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 4/4] test/ring: add check to validate the dequeued objects Feifei Wang
  3 siblings, 0 replies; 20+ messages in thread
From: Feifei Wang @ 2020-08-05  6:14 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev, Olivier Matz, Gavin Hu
  Cc: dev, nd, Feifei Wang, stable

The actual capacity of ring should be the (RING_SIZE - 1), thus only
(RING_SIZE - 1) elements can be enqueued into the ring.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 app/test/test_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index c508a13a9..51bae0d48 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -822,7 +822,7 @@ test_ring_basic_ex(void)
 		printf("%u ring entries are now free\n",
 			rte_ring_free_count(rp));
 
-		for (j = 0; j < RING_SIZE; j++) {
+		for (j = 0; j < RING_SIZE - 1; j++) {
 			test_ring_enqueue(rp, obj, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		}
@@ -833,7 +833,7 @@ test_ring_basic_ex(void)
 			goto fail_test;
 		}
 
-		for (j = 0; j < RING_SIZE; j++) {
+		for (j = 0; j < RING_SIZE - 1; j++) {
 			test_ring_dequeue(rp, obj, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [dpdk-dev] [PATCH v2 4/4] test/ring: add check to validate the dequeued objects
  2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
                     ` (2 preceding siblings ...)
  2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements Feifei Wang
@ 2020-08-05  6:14   ` Feifei Wang
  3 siblings, 0 replies; 20+ messages in thread
From: Feifei Wang @ 2020-08-05  6:14 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Konstantin Ananyev; +Cc: dev, nd, Feifei Wang

For the single element enqueue and dequeue in test_ring_basic_ex and
test_ring_with_exact_size, add check to validate the dequeued objects.

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
 app/test/test_ring.c | 145 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 109 insertions(+), 36 deletions(-)

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 51bae0d48..a1ff73a05 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -791,15 +791,9 @@ test_ring_basic_ex(void)
 	int ret = -1;
 	unsigned int i, j;
 	struct rte_ring *rp = NULL;
-	void *obj = NULL;
+	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 
 	for (i = 0; i < RTE_DIM(esize); i++) {
-		obj = test_ring_calloc(RING_SIZE, esize[i]);
-		if (obj == NULL) {
-			printf("%s: failed to alloc memory\n", __func__);
-			goto fail_test;
-		}
-
 		rp = test_ring_create("test_ring_basic_ex", esize[i], RING_SIZE,
 					SOCKET_ID_ANY,
 					RING_F_SP_ENQ | RING_F_SC_DEQ);
@@ -808,6 +802,23 @@ test_ring_basic_ex(void)
 			goto fail_test;
 		}
 
+		/* alloc dummy object pointers */
+		src = test_ring_calloc(RING_SIZE, esize[i]);
+		if (src == NULL) {
+			printf("%s: failed to alloc src memory\n", __func__);
+			goto fail_test;
+		}
+		test_ring_mem_init(src, RING_SIZE, esize[i]);
+		cur_src = src;
+
+		/* alloc some room for copied objects */
+		dst = test_ring_calloc(RING_SIZE, esize[i]);
+		if (dst == NULL) {
+			printf("%s: failed to alloc dst memory\n", __func__);
+			goto fail_test;
+		}
+		cur_dst = dst;
+
 		if (rte_ring_lookup("test_ring_basic_ex") != rp) {
 			printf("%s: failed to find ring\n", __func__);
 			goto fail_test;
@@ -823,8 +834,9 @@ test_ring_basic_ex(void)
 			rte_ring_free_count(rp));
 
 		for (j = 0; j < RING_SIZE - 1; j++) {
-			test_ring_enqueue(rp, obj, esize[i], 1,
+			test_ring_enqueue(rp, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+			cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
 		}
 
 		if (rte_ring_full(rp) != 1) {
@@ -834,8 +846,9 @@ test_ring_basic_ex(void)
 		}
 
 		for (j = 0; j < RING_SIZE - 1; j++) {
-			test_ring_dequeue(rp, obj, esize[i], 1,
+			test_ring_dequeue(rp, cur_dst, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+			cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);
 		}
 
 		if (rte_ring_empty(rp) != 1) {
@@ -844,52 +857,88 @@ test_ring_basic_ex(void)
 			goto fail_test;
 		}
 
+		/* check data */
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_src, src))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
+			printf("data after dequeue is not the same\n");
+			goto fail_test;
+		}
+
+
 		/* Following tests use the configured flags to decide
 		 * SP/SC or MP/MC.
 		 */
+		/* reset dst */
+		if (esize[i] == -1)
+			memset(dst, 0, RING_SIZE * sizeof(void *));
+		else
+			memset(dst, 0, RING_SIZE * esize[i]);
+
+		/* reset cur_src and cur_dst */
+		cur_src = src;
+		cur_dst = dst;
+
 		/* Covering the ring burst operation */
-		ret = test_ring_enqueue(rp, obj, esize[i], 2,
+		ret = test_ring_enqueue(rp, cur_src, esize[i], 2,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
 		if (ret != 2) {
 			printf("%s: rte_ring_enqueue_burst fails\n", __func__);
 			goto fail_test;
 		}
+		cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
 
-		ret = test_ring_dequeue(rp, obj, esize[i], 2,
+		ret = test_ring_dequeue(rp, cur_dst, esize[i], 2,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
 		if (ret != 2) {
 			printf("%s: rte_ring_dequeue_burst fails\n", __func__);
 			goto fail_test;
 		}
+		cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
 
 		/* Covering the ring bulk operation */
-		ret = test_ring_enqueue(rp, obj, esize[i], 2,
+		ret = test_ring_enqueue(rp, cur_src, esize[i], 2,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);
 		if (ret != 2) {
 			printf("%s: rte_ring_enqueue_bulk fails\n", __func__);
 			goto fail_test;
 		}
+		cur_src = test_ring_inc_ptr(cur_src, esize[i], 2);
 
-		ret = test_ring_dequeue(rp, obj, esize[i], 2,
+		ret = test_ring_dequeue(rp, cur_dst, esize[i], 2,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);
 		if (ret != 2) {
 			printf("%s: rte_ring_dequeue_bulk fails\n", __func__);
 			goto fail_test;
 		}
+		cur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);
+
+		/* check data */
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
+			printf("data after dequeue is not the same\n");
+			goto fail_test;
+		}
 
 		rte_ring_free(rp);
-		rte_free(obj);
+		rte_free(src);
+		rte_free(dst);
 		rp = NULL;
-		obj = NULL;
+		src = NULL;
+		dst = NULL;
 	}
 
 	return 0;
 
 fail_test:
 	rte_ring_free(rp);
-	if (obj != NULL)
-		rte_free(obj);
-
+	rte_free(src);
+	rte_free(dst);
 	return -1;
 }
 
@@ -900,8 +949,8 @@ static int
 test_ring_with_exact_size(void)
 {
 	struct rte_ring *std_r = NULL, *exact_sz_r = NULL;
-	void *obj_orig;
-	void *obj;
+	void **src_orig = NULL, **dst_orig = NULL;
+	void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;
 	const unsigned int ring_sz = 16;
 	unsigned int i, j;
 	int ret = -1;
@@ -911,14 +960,6 @@ test_ring_with_exact_size(void)
 				TEST_RING_IGNORE_API_TYPE,
 				esize[i]);
 
-		/* alloc object pointers. Allocate one extra object
-		 * and create an unaligned address.
-		 */
-		obj_orig = test_ring_calloc(17, esize[i]);
-		if (obj_orig == NULL)
-			goto test_fail;
-		obj = ((char *)obj_orig) + 1;
-
 		std_r = test_ring_create("std", esize[i], ring_sz,
 					rte_socket_id(),
 					RING_F_SP_ENQ | RING_F_SC_DEQ);
@@ -936,6 +977,22 @@ test_ring_with_exact_size(void)
 			goto test_fail;
 		}
 
+		/* alloc object pointers. Allocate one extra object
+		 * and create an unaligned address.
+		 */
+		src_orig = test_ring_calloc(17, esize[i]);
+		if (src_orig == NULL)
+			goto test_fail;
+		test_ring_mem_init(src_orig, 17, esize[i]);
+		src = ((void **)src_orig) + 1;
+		cur_src = src;
+
+		dst_orig = test_ring_calloc(17, esize[i]);
+		if (dst_orig == NULL)
+			goto test_fail;
+		dst = ((void **)dst_orig) + 1;
+		cur_dst = dst;
+
 		/*
 		 * Check that the exact size ring is bigger than the
 		 * standard ring
@@ -952,33 +1009,36 @@ test_ring_with_exact_size(void)
 		 * than the standard ring. (16 vs 15 elements)
 		 */
 		for (j = 0; j < ring_sz - 1; j++) {
-			test_ring_enqueue(std_r, obj, esize[i], 1,
+			test_ring_enqueue(std_r, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
-			test_ring_enqueue(exact_sz_r, obj, esize[i], 1,
+			test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
+			cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
 		}
-		ret = test_ring_enqueue(std_r, obj, esize[i], 1,
+		ret = test_ring_enqueue(std_r, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		if (ret != -ENOBUFS) {
 			printf("%s: error, unexpected successful enqueue\n",
 				__func__);
 			goto test_fail;
 		}
-		ret = test_ring_enqueue(exact_sz_r, obj, esize[i], 1,
+		ret = test_ring_enqueue(exact_sz_r, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		if (ret == -ENOBUFS) {
 			printf("%s: error, enqueue failed\n", __func__);
 			goto test_fail;
 		}
+		cur_src = test_ring_inc_ptr(cur_src, esize[i], 1);
 
 		/* check that dequeue returns the expected number of elements */
-		ret = test_ring_dequeue(exact_sz_r, obj, esize[i], ring_sz,
+		ret = test_ring_dequeue(exact_sz_r, cur_dst, esize[i], ring_sz,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);
 		if (ret != (int)ring_sz) {
 			printf("%s: error, failed to dequeue expected nb of elements\n",
 				__func__);
 			goto test_fail;
 		}
+		cur_dst = test_ring_inc_ptr(cur_dst, esize[i], ring_sz);
 
 		/* check that the capacity function returns expected value */
 		if (rte_ring_get_capacity(exact_sz_r) != ring_sz) {
@@ -987,10 +1047,22 @@ test_ring_with_exact_size(void)
 			goto test_fail;
 		}
 
-		rte_free(obj_orig);
+		/* check data */
+		if (memcmp(src, dst, RTE_PTR_DIFF(cur_dst, dst))) {
+			rte_hexdump(stdout, "src", src,
+					RTE_PTR_DIFF(cur_src, src));
+			rte_hexdump(stdout, "dst", dst,
+					RTE_PTR_DIFF(cur_dst, dst));
+			printf("data after dequeue is not the same\n");
+			goto test_fail;
+		}
+
+		rte_free(src_orig);
+		rte_free(dst_orig);
 		rte_ring_free(std_r);
 		rte_ring_free(exact_sz_r);
-		obj_orig = NULL;
+		src_orig = NULL;
+		dst_orig = NULL;
 		std_r = NULL;
 		exact_sz_r = NULL;
 	}
@@ -998,7 +1070,8 @@ test_ring_with_exact_size(void)
 	return 0;
 
 test_fail:
-	rte_free(obj_orig);
+	rte_free(src_orig);
+	rte_free(dst_orig);
 	rte_ring_free(std_r);
 	rte_ring_free(exact_sz_r);
 	return -1;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, back to index

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29  6:31 [dpdk-dev] [PATCH v1 0/2] wrong pointer passed of ring Feifei Wang
2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 1/2] ring: fix the misdescription of the param Feifei Wang
2020-07-29 15:59   ` David Marchand
2020-07-29 16:24     ` Ananyev, Konstantin
2020-07-29 19:34       ` Honnappa Nagarahalli
2020-07-30 10:16     ` [dpdk-dev] 回复: " Feifei Wang
2020-07-31  5:26       ` [dpdk-dev] " Honnappa Nagarahalli
2020-07-29  6:31 ` [dpdk-dev] [PATCH v1 2/2] test/ring: fix wrong param passed to the enqueue APIs Feifei Wang
2020-07-29 13:48   ` David Marchand
2020-07-29 14:16     ` [dpdk-dev] 回复: " Feifei Wang
2020-07-29 14:21       ` [dpdk-dev] " David Marchand
2020-07-29 15:03         ` [dpdk-dev] 回复: " Feifei Wang
2020-07-29 21:24           ` [dpdk-dev] " Honnappa Nagarahalli
2020-07-30 10:28             ` [dpdk-dev] 回复: " Feifei Wang
2020-07-31  6:25               ` Feifei Wang
2020-08-05  6:14 ` [dpdk-dev] [PATCH v2 0/4] wrong pointer passed and add check Feifei Wang
2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 1/4] test/ring: fix wrong parameter passed to the enqueue APIs Feifei Wang
2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 2/4] test/ring: fix wrong size used in memcmp Feifei Wang
2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements Feifei Wang
2020-08-05  6:14   ` [dpdk-dev] [PATCH v2 4/4] test/ring: add check to validate the dequeued objects Feifei Wang

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox