DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert "examples/symmetric_mp: do not print or exit in handler"
@ 2026-10-27 15:07 Stephen Hemminger
  2026-10-27 16:10 ` Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Hemminger @ 2026-10-27 15:07 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Anatoly Burakov

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

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/multi_process/symmetric_mp/main.c | 30 +++++++++-------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index e2d185ab1b..05f61abedb 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -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();
-- 
2.53.0


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

end of thread, other threads:[~2026-10-27 20:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 15:07 [PATCH] Revert "examples/symmetric_mp: do not print or exit in handler" Stephen Hemminger
2026-10-27 16:10 ` Stephen Hemminger
2026-10-27 20:23 ` [PATCH v2] " Stephen Hemminger
2026-10-27 20:28 ` [PATCH v3] " Stephen Hemminger

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