Revert "examples/symmetric_mp: do not print or exit in handler"
PATCH 1/1 Revert "examples/symmetric_mp: do not print or exit in handler"
This reverts commit 9a0b3c409db1963a92d0a91868b1e45254845a8c.
With that change the primary calls rte_eal_cleanup() on SIGINT while secondaries are still polling the shared queues, which crashes the secondaries.
Doing shutdown correctly in a multi-process application needs both processes to monitor each other and handle termination and unexpected exit. That is too complex for an example; go back to the simple exit from the signal handler.
Bugzilla ID: 2069
--- examples/multi_process/symmetric_mp/main.c | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-)
examples/multi_process/symmetric_mp/main.c +12 -18
@@ -92,17 +92,15 @@ smp_usage(const char *prgname, const char *errmsg) } -/* Set by SIGTERM and SIGINT handler to stop the forwarding loops. */ -static volatile sig_atomic_t quit; - -static void -signal_handler(__rte_unused int signum) -{ - quit =1 ; -} - +/* +* Signal handler configured for SIGTERM and SIGINT to print stats on exit +* +* This is not safe way to exit for a real production application; it is just an example. +* Doing proper shutdown with primary/secondary requires process monitoring +* and rendezvous. +*/ static void -print_stats (void ) +print_stats (int signum) {unsigned i;
@@ -111,6 +109,7 @@ print_stats(void)printf ("Port %u: RX - %u, TX - %u, Drop - %u\n" , (unsigned )p_num, pstats[p_num].rx, pstats[p_num].tx, pstats[p_num].drop); } +exit (0 ); }/* Parse the argument given in the command line of the application */
@@ -351,7 +350,7 @@ lcore_main(void *arg __rte_unused)* queue number corresponding to our process number (not lcore id) */ -while (!quit) { +for (;;) {struct rte_mbuf *buf[PKT_BURST ];for (p = start_port; p < end_port; p++) {
@@ -371,8 +370,6 @@ lcore_main(void *arg __rte_unused) } } } - -return 0 ; }/* Check the link status of all ports in up to 9s, and print them finally */
@@ -449,8 +446,8 @@ main(int argc, char **argv)struct rte_mempool *mp;/* set up signal handlers to print stats on exit */ -signal (SIGINT , signal_handler); -signal (SIGTERM , signal_handler); +signal (SIGINT , print_stats); +signal (SIGTERM , print_stats);/* initialise the EAL for all */ ret =rte_eal_init (argc, argv);
@@ -493,9 +490,6 @@ main(int argc, char **argv)RTE_LOG (INFO ,APP ,"Finished Process Init.\n" );rte_eal_mp_remote_launch (lcore_main,NULL ,CALL_MAIN ); -rte_eal_mp_wait_lcore (); - -print_stats ();/* clean up the EAL */ rte_eal_cleanup ();
Signature · 1 line
2.53.0
examples/multi_process/symmetric_mp/main.c smp_usage(const char *prgname, const char *errmsg) · line 104
Quoted 11 lines · On Tue, 27 Oct 2026 08:07:48 -0700 Stephen Hemminger…
examples/multi_process/symmetric_mp/main.c +8
-1+/* +* Signal handler configured for SIGTERM and SIGINT to print stats on exit +* +* This is not safe way to exit for a real production application; it is just an example. +* Doing proper shutdown with primary/secondary requires process monitoring +* and rendezvous. +*/ static void -print_stats (void ) +print_stats (int signum) {
Needs fix to add __rte_unused here.
PATCH v2 1/1 Revert "examples/symmetric_mp: do not print or exit in handler"
In reply to Stephen HemmingerThis reverts commit 9a0b3c409db1963a92d0a91868b1e45254845a8c.
With that change the primary calls rte_eal_cleanup() on SIGINT while secondaries are still polling the shared queues, which crashes the secondaries.
Doing shutdown correctly in a multi-process application needs both processes to monitor each other and handle termination and unexpected exit. That is too complex for an example; go back to the simple exit from the signal handler.
Bugzilla ID: 2069
---
v2 - need to mark arg unused
examples/multi_process/symmetric_mp/main.c | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-)
examples/multi_process/symmetric_mp/main.c +12 -18
@@ -92,17 +92,15 @@ smp_usage(const char *prgname, const char *errmsg) } -/* Set by SIGTERM and SIGINT handler to stop the forwarding loops. */ -static volatile sig_atomic_t quit; - -static void -signal_handler(__rte_unused int signum) -{ - quit =1 ; -} - +/* +* Signal handler configured for SIGTERM and SIGINT to print stats on exit +* +* This is not safe way to exit for a real production application; it is just an example. +* Doing proper shutdown with primary/secondary requires process monitoring +* and rendezvous. +*/ static void -print_stats (void ) +print_stats (int signum) {unsigned i;
@@ -111,6 +109,7 @@ print_stats(void)printf ("Port %u: RX - %u, TX - %u, Drop - %u\n" , (unsigned )p_num, pstats[p_num].rx, pstats[p_num].tx, pstats[p_num].drop); } +exit (0 ); }/* Parse the argument given in the command line of the application */
@@ -351,7 +350,7 @@ lcore_main(void *arg __rte_unused)* queue number corresponding to our process number (not lcore id) */ -while (!quit) { +for (;;) {struct rte_mbuf *buf[PKT_BURST ];for (p = start_port; p < end_port; p++) {
@@ -371,8 +370,6 @@ lcore_main(void *arg __rte_unused) } } } - -return 0 ; }/* Check the link status of all ports in up to 9s, and print them finally */
@@ -449,8 +446,8 @@ main(int argc, char **argv)struct rte_mempool *mp;/* set up signal handlers to print stats on exit */ -signal (SIGINT , signal_handler); -signal (SIGTERM , signal_handler); +signal (SIGINT , print_stats); +signal (SIGTERM , print_stats);/* initialise the EAL for all */ ret =rte_eal_init (argc, argv);
@@ -493,9 +490,6 @@ main(int argc, char **argv)RTE_LOG (INFO ,APP ,"Finished Process Init.\n" );rte_eal_mp_remote_launch (lcore_main,NULL ,CALL_MAIN ); -rte_eal_mp_wait_lcore (); - -print_stats ();/* clean up the EAL */ rte_eal_cleanup ();
Signature · 1 line
2.53.0
PATCH v3 1/1 Revert "examples/symmetric_mp: do not print or exit in handler"
In reply to Stephen HemmingerThis reverts commit 9a0b3c409db1963a92d0a91868b1e45254845a8c.
With that change the primary calls rte_eal_cleanup() on SIGINT while secondaries are still polling the shared queues, which crashes the secondaries.
Doing shutdown correctly in a multi-process application needs both processes to monitor each other and handle termination and unexpected exit. That is too complex for an example; go back to the simple exit from the signal handler.
Bugzilla ID: 2069
---
v3 - need to ignore signum, send correct commit
examples/multi_process/symmetric_mp/main.c | 30 +++++++++------------- 1 file changed, 12 insertions(+), 18 deletions(-)
examples/multi_process/symmetric_mp/main.c +12 -18
@@ -92,17 +92,15 @@ smp_usage(const char *prgname, const char *errmsg) } -/* Set by SIGTERM and SIGINT handler to stop the forwarding loops. */ -static volatile sig_atomic_t quit; - -static void -signal_handler(__rte_unused int signum) -{ - quit =1 ; -} - +/* +* Signal handler configured for SIGTERM and SIGINT to print stats on exit +* +* This is not safe way to exit for a real production application; it is just an example. +* Doing proper shutdown with primary/secondary requires process monitoring +* and rendezvous. +*/ static void -print_stats (void ) +print_stats(int signum __rte_unused) {unsigned i;
@@ -111,6 +109,7 @@ print_stats(void)printf ("Port %u: RX - %u, TX - %u, Drop - %u\n" , (unsigned )p_num, pstats[p_num].rx, pstats[p_num].tx, pstats[p_num].drop); } +exit (0 ); }/* Parse the argument given in the command line of the application */
@@ -351,7 +350,7 @@ lcore_main(void *arg __rte_unused)* queue number corresponding to our process number (not lcore id) */ -while (!quit) { +for (;;) {struct rte_mbuf *buf[PKT_BURST ];for (p = start_port; p < end_port; p++) {
@@ -371,8 +370,6 @@ lcore_main(void *arg __rte_unused) } } } - -return 0 ; }/* Check the link status of all ports in up to 9s, and print them finally */
@@ -449,8 +446,8 @@ main(int argc, char **argv)struct rte_mempool *mp;/* set up signal handlers to print stats on exit */ -signal (SIGINT , signal_handler); -signal (SIGTERM , signal_handler); +signal (SIGINT , print_stats); +signal (SIGTERM , print_stats);/* initialise the EAL for all */ ret =rte_eal_init (argc, argv);
@@ -493,9 +490,6 @@ main(int argc, char **argv)RTE_LOG (INFO ,APP ,"Finished Process Init.\n" );rte_eal_mp_remote_launch (lcore_main,NULL ,CALL_MAIN ); -rte_eal_mp_wait_lcore (); - -print_stats ();/* clean up the EAL */ rte_eal_cleanup ();
Signature · 1 line
2.53.0
David Marchand
AppliedQuoted 7 lines · Stephen Hemminger
This reverts commit
9a0b3c409db1963a92d0a91868b1e45254845a8c.With that change the primary calls
rte_eal_cleanup()on SIGINT while secondaries are still polling the shared queues, which crashes the secondaries.
Quoted 8 lines
Doing shutdown correctly in a multi-process application needs both processes to monitor each other and handle termination and unexpected exit. That is too complex for an example; go back to the simple exit from the signal handler.
Bugzilla ID: 2069
Signed-off-by Stephen Hemminger <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand