public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/1] aio-stress.c: Remove useless iteration variable
@ 2022-12-23 18:33 Petr Vorel
  2023-01-09 14:11 ` Richard Palethorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Vorel @ 2022-12-23 18:33 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

local iteration variable in worker() was probably left over from
previous version before rewrite because clang correctly reported also on
this old version:

    aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
    int iteration = 0;

Whole restart label was not used.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* remove whole restart label.

 testcases/kernel/io/ltp-aiodio/aio-stress.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index 2fdbb84e87..2946ac1f47 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -1039,12 +1039,10 @@ static int *worker(struct thread_info *t)
 	char *this_stage = NULL;
 	struct timeval stage_time;
 	int status = 0;
-	int iteration = 0;
 	int cnt;
 
 	aio_setup(&t->io_ctx, 512);
 
-restart:
 	if (num_threads > 1) {
 		if (pthread_barrier_wait(&worker_barrier))
 			gettimeofday(&global_stage_start_time, NULL);
@@ -1115,12 +1113,6 @@ restart:
 			global_thread_throughput(t, this_stage);
 	}
 
-	/* someone got restarted, go back to the beginning */
-	if (t->active_opers && cnt < iterations) {
-		iteration++;
-		goto restart;
-	}
-
 	/* finally, free all the ram */
 	while (t->finished_opers) {
 		oper = t->finished_opers;
-- 
2.39.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2 1/1] aio-stress.c: Remove useless iteration variable
  2022-12-23 18:33 [LTP] [PATCH v2 1/1] aio-stress.c: Remove useless iteration variable Petr Vorel
@ 2023-01-09 14:11 ` Richard Palethorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Palethorpe @ 2023-01-09 14:11 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hello,

Petr Vorel <pvorel@suse.cz> writes:

> local iteration variable in worker() was probably left over from
> previous version before rewrite because clang correctly reported also on
> this old version:
>
>     aio-stress.c:1049:6: warning: variable 'iteration' set but not used [-Wunused-but-set-variable]
>     int iteration = 0;
>
> Whole restart label was not used.
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Changes v1->v2:
> * remove whole restart label.
>
>  testcases/kernel/io/ltp-aiodio/aio-stress.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> index 2fdbb84e87..2946ac1f47 100644
> --- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
> +++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
> @@ -1039,12 +1039,10 @@ static int *worker(struct thread_info *t)
>  	char *this_stage = NULL;
>  	struct timeval stage_time;
>  	int status = 0;
> -	int iteration = 0;
>  	int cnt;
>  
>  	aio_setup(&t->io_ctx, 512);
>  
> -restart:
>  	if (num_threads > 1) {
>  		if (pthread_barrier_wait(&worker_barrier))
>  			gettimeofday(&global_stage_start_time, NULL);
> @@ -1115,12 +1113,6 @@ restart:
>  			global_thread_throughput(t, this_stage);
>  	}
>  
> -	/* someone got restarted, go back to the beginning */
> -	if (t->active_opers && cnt < iterations) {

In this case, shouldn't we remove all the restart code? It seems
active_opers can be added to and cnt could be less than iterations. So
the label could be used.

I think you are safe to remove only the iteration variable.

Personally I would not touch this code except to fix a major issue or
rewrite it altogether.

> -		iteration++;
> -		goto restart;
> -	}
> -
>  	/* finally, free all the ram */
>  	while (t->finished_opers) {
>  		oper = t->finished_opers;
> -- 
> 2.39.0


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2023-01-09 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-23 18:33 [LTP] [PATCH v2 1/1] aio-stress.c: Remove useless iteration variable Petr Vorel
2023-01-09 14:11 ` Richard Palethorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox