diff mbox series

[2/2] test: proceed if timer subsystem was initialized

Message ID 20210326104759.280175-3-mk@semihalf.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers show
Series Fix unit tests execution for ENA PMD | expand

Checks

Context Check Description
ci/travis-robot warning travis build: errored
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Michał Krawczyk March 26, 2021, 10:47 a.m. UTC
From: Stanislaw Kardach <kda@semihalf.com>

rte_timer_subsystem_init() may return -EALREADY if the timer subsystem
was already initialized. This can happen i.e. in PMD code (see
eth_ena_dev_init). This is not an error, rather a notification as the
initialization function simply returns without any action taken.

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Reviewed-by: Michal Krawczyk <mk@semihalf.com>
---
 app/test/test.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Thomas Monjalon April 6, 2021, 3:24 p.m. UTC | #1
26/03/2021 11:47, Michal Krawczyk:
> From: Stanislaw Kardach <kda@semihalf.com>
> 
> rte_timer_subsystem_init() may return -EALREADY if the timer subsystem
> was already initialized. This can happen i.e. in PMD code (see
> eth_ena_dev_init). This is not an error, rather a notification as the
> initialization function simply returns without any action taken.

Missing these lines:

Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
Cc: stable@dpdk.org

> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> Reviewed-by: Michal Krawczyk <mk@semihalf.com>
> ---
>  app/test/test.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/app/test/test.c b/app/test/test.c
> index 624dd48042..864523ed61 100644
> --- a/app/test/test.c
> +++ b/app/test/test.c
> @@ -134,8 +134,13 @@ main(int argc, char **argv)
>  		goto out;
>  	}
>  
> +	argv += ret;
> +
> +	prgname = argv[0];
> +
>  #ifdef RTE_LIB_TIMER
> -	if (rte_timer_subsystem_init() < 0) {
> +	ret = rte_timer_subsystem_init();
> +	if (ret < 0 && ret != -EALREADY) {
>  		ret = -1;
>  		goto out;
>  	}
> @@ -146,10 +151,6 @@ main(int argc, char **argv)
>  		goto out;
>  	}
>  
> -	argv += ret;
> -
> -	prgname = argv[0];
> -

How this change for argv/prgname is related to the fix?
Stanislaw Kardach April 6, 2021, 3:31 p.m. UTC | #2
Hi Thomas,

Thanks for the review.

On Tue, Apr 6, 2021 at 5:24 PM Thomas Monjalon <thomas@monjalon.net> wrote:

> 26/03/2021 11:47, Michal Krawczyk:
> > From: Stanislaw Kardach <kda@semihalf.com>
> >
> > rte_timer_subsystem_init() may return -EALREADY if the timer subsystem
> > was already initialized. This can happen i.e. in PMD code (see
> > eth_ena_dev_init). This is not an error, rather a notification as the
> > initialization function simply returns without any action taken.
>
> Missing these lines:
>
> Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
> Cc: stable@dpdk.org

Will add in V2.

>
>
> > Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> > Reviewed-by: Michal Krawczyk <mk@semihalf.com>
> > ---
> >  app/test/test.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/app/test/test.c b/app/test/test.c
> > index 624dd48042..864523ed61 100644
> > --- a/app/test/test.c
> > +++ b/app/test/test.c
> > @@ -134,8 +134,13 @@ main(int argc, char **argv)
> >               goto out;
> >       }
> >
> > +     argv += ret;
> > +
> > +     prgname = argv[0];
> > +
> >  #ifdef RTE_LIB_TIMER
> > -     if (rte_timer_subsystem_init() < 0) {
> > +     ret = rte_timer_subsystem_init();
> > +     if (ret < 0 && ret != -EALREADY) {
> >               ret = -1;
> >               goto out;
> >       }
> > @@ -146,10 +151,6 @@ main(int argc, char **argv)
> >               goto out;
> >       }
> >
> > -     argv += ret;
> > -
> > -     prgname = argv[0];
> > -
>
> How this change for argv/prgname is related to the fix?
>
This patch saves the return value of  rte_timer_subsystem_init() in ret
which overwrites the previous ret that held the number of arguments
consumed by rte_eal_init(). Similarly because rte_eal_init() reshuffles
argv, the prgname is effectively at argv[ret]. So I need to move this logic
before the timer subsystem check.
Thomas Monjalon April 6, 2021, 3:40 p.m. UTC | #3
06/04/2021 17:31, Stanisław Kardach:
> Hi Thomas,
> 
> Thanks for the review.
> 
> On Tue, Apr 6, 2021 at 5:24 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> 
> > 26/03/2021 11:47, Michal Krawczyk:
> > > From: Stanislaw Kardach <kda@semihalf.com>
> > >
> > > rte_timer_subsystem_init() may return -EALREADY if the timer subsystem
> > > was already initialized. This can happen i.e. in PMD code (see
> > > eth_ena_dev_init). This is not an error, rather a notification as the
> > > initialization function simply returns without any action taken.
> >
> > Missing these lines:
> >
> > Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
> > Cc: stable@dpdk.org
> 
> Will add in V2.
> 
> >
> >
> > > Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
> > > Reviewed-by: Michal Krawczyk <mk@semihalf.com>
> > > ---
> > >  app/test/test.c | 11 ++++++-----
> > >  1 file changed, 6 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/app/test/test.c b/app/test/test.c
> > > index 624dd48042..864523ed61 100644
> > > --- a/app/test/test.c
> > > +++ b/app/test/test.c
> > > @@ -134,8 +134,13 @@ main(int argc, char **argv)
> > >               goto out;
> > >       }
> > >
> > > +     argv += ret;
> > > +
> > > +     prgname = argv[0];
> > > +
> > >  #ifdef RTE_LIB_TIMER
> > > -     if (rte_timer_subsystem_init() < 0) {
> > > +     ret = rte_timer_subsystem_init();
> > > +     if (ret < 0 && ret != -EALREADY) {
> > >               ret = -1;
> > >               goto out;
> > >       }
> > > @@ -146,10 +151,6 @@ main(int argc, char **argv)
> > >               goto out;
> > >       }
> > >
> > > -     argv += ret;
> > > -
> > > -     prgname = argv[0];
> > > -
> >
> > How this change for argv/prgname is related to the fix?
> >
> This patch saves the return value of  rte_timer_subsystem_init() in ret
> which overwrites the previous ret that held the number of arguments
> consumed by rte_eal_init(). Similarly because rte_eal_init() reshuffles
> argv, the prgname is effectively at argv[ret]. So I need to move this logic
> before the timer subsystem check.

OK I didn't see the consequence on ret variable.
In this case I can merge with the added lines.
No need of v2.
diff mbox series

Patch

diff --git a/app/test/test.c b/app/test/test.c
index 624dd48042..864523ed61 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -134,8 +134,13 @@  main(int argc, char **argv)
 		goto out;
 	}
 
+	argv += ret;
+
+	prgname = argv[0];
+
 #ifdef RTE_LIB_TIMER
-	if (rte_timer_subsystem_init() < 0) {
+	ret = rte_timer_subsystem_init();
+	if (ret < 0 && ret != -EALREADY) {
 		ret = -1;
 		goto out;
 	}
@@ -146,10 +151,6 @@  main(int argc, char **argv)
 		goto out;
 	}
 
-	argv += ret;
-
-	prgname = argv[0];
-
 	recursive_call = getenv(RECURSIVE_ENV_VAR);
 	if (recursive_call != NULL) {
 		ret = do_recursive_call();