[RFC,1/2] testpmd: make f_quit flag volatile

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Oct. 14, 2022, 5:23 p.m. UTC
  Since f_quit is set in a signal handler it needs
to be marked as volatile. Otherwise, compler is allowed
to optimize away access to it.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-pmd/testpmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Andrew Rybchenko Nov. 6, 2022, 10:48 a.m. UTC | #1
On 10/14/22 20:23, Stephen Hemminger wrote:
> Since f_quit is set in a signal handler it needs
> to be marked as volatile. Otherwise, compler is allowed

compler -> compiler

> to optimize away access to it.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

I need non-RFC version to apply it.
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 5b0f0838dcc8..815dd6dab4e3 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. */
 
 /*