[v2] testpmd: make f_quit flag volatile

Message ID 20221108180743.20390-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Andrew Rybchenko
Headers
Series [v2] testpmd: make f_quit flag volatile |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Stephen Hemminger Nov. 8, 2022, 6:07 p.m. UTC
  Since f_quit is set in a signal handler it needs to be marked
volatile.  Otherwise, compiler is allowed to optimize the loop because
it can assume the value never changes. The flag can also be made local
to the file it is used in.

Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - not RFC and add fixes line

 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ruifeng Wang Nov. 9, 2022, 10:11 a.m. UTC | #1
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Wednesday, November 9, 2022 2:08 AM
> To: dev@dpdk.org
> Cc: Phil Yang <Phil.Yang@arm.com>; Stephen Hemminger <stephen@networkplumber.org>
> Subject: [PATCH v2] testpmd: make f_quit flag volatile
> 
> Since f_quit is set in a signal handler it needs to be marked volatile.  Otherwise,
> compiler is allowed to optimize the loop because it can assume the value never changes.
> The flag can also be made local to the file it is used in.
> 
> Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v2 - not RFC and add fixes line
> 
>  app/test-pmd/testpmd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> aa7ea29f15ba..cf5942d0c422 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -231,7 +231,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to
> show */
>   * In container, it cannot terminate the process which running with 'stats-period'
>   * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.
>   */
> -uint8_t f_quit;
> +static volatile uint8_t f_quit;
>  uint8_t cl_quit; /* Quit testpmd from cmdline. */
> 
>  /*
> --
> 2.35.1
Thanks for the change.
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
  
Andrew Rybchenko Nov. 9, 2022, 10:37 a.m. UTC | #2
On 11/9/22 13:11, Ruifeng Wang wrote:
>> -----Original Message-----
>> From: Stephen Hemminger <stephen@networkplumber.org>
>> Sent: Wednesday, November 9, 2022 2:08 AM
>> To: dev@dpdk.org
>> Cc: Phil Yang <Phil.Yang@arm.com>; Stephen Hemminger <stephen@networkplumber.org>
>> Subject: [PATCH v2] testpmd: make f_quit flag volatile
>>
>> Since f_quit is set in a signal handler it needs to be marked volatile.  Otherwise,
>> compiler is allowed to optimize the loop because it can assume the value never changes.
>> The flag can also be made local to the file it is used in.
>>
>> Fixes: d9a191a00e81 ("app/testpmd: fix quitting in container")
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>> ---
>> v2 - not RFC and add fixes line
>>
>>   app/test-pmd/testpmd.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>> aa7ea29f15ba..cf5942d0c422 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -231,7 +231,7 @@ unsigned int xstats_display_num; /**< Size of extended statistics to
>> show */
>>    * In container, it cannot terminate the process which running with 'stats-period'
>>    * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.
>>    */
>> -uint8_t f_quit;
>> +static volatile uint8_t f_quit;
>>   uint8_t cl_quit; /* Quit testpmd from cmdline. */
>>
>>   /*
>> --
>> 2.35.1
> Thanks for the change.
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index aa7ea29f15ba..cf5942d0c422 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -231,7 +231,7 @@  unsigned int xstats_display_num; /**< Size of extended statistics to show */
  * In container, it cannot terminate the process which running with 'stats-period'
  * option. Set flag to exit stats period loop after received SIGINT/SIGTERM.
  */
-uint8_t f_quit;
+static volatile uint8_t f_quit;
 uint8_t cl_quit; /* Quit testpmd from cmdline. */
 
 /*