DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples/multi_process: fix cleanup on exit
@ 2025-07-08  7:09 Maayan Kashani
  2025-07-09 13:30 ` Burakov, Anatoly
  2025-07-09 15:01 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Maayan Kashani @ 2025-07-08  7:09 UTC (permalink / raw)
  To: dev; +Cc: mkashani, rasland, stable, Anatoly Burakov

Device was started but not stopped on exit signal.
Added port stop and close on exit.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
---
 examples/multi_process/symmetric_mp/main.c | 27 ++++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index f7d8439cd4e..de16608a0fb 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -92,6 +92,25 @@ smp_usage(const char *prgname, const char *errmsg)
 	exit(1);
 }
 
+static void
+exit_cleanup(void)
+{
+	unsigned int i;
+
+	RTE_LOG(INFO, APP, "Close ports.\n");
+	for (i = 0; i < num_ports; i++) {
+		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			if (rte_eth_dev_stop(ports[i]))
+				rte_exit(EXIT_FAILURE, "Error stopping ports\n");
+			if (rte_eth_dev_close(ports[i]))
+				rte_exit(EXIT_FAILURE, "Error closing ports\n");
+		}
+	}
+
+	/* clean up the EAL */
+	rte_eal_cleanup();
+	exit(0);
+}
 
 /* signal handler configured for SIGTERM and SIGINT to print stats on exit */
 static void
@@ -104,9 +123,10 @@ print_stats(int signum)
 		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);
+	exit_cleanup();
 }
 
+
 /* Parse the argument given in the command line of the application */
 static int
 smp_parse_args(int argc, char **argv)
@@ -486,8 +506,5 @@ main(int argc, char **argv)
 
 	rte_eal_mp_remote_launch(lcore_main, NULL, CALL_MAIN);
 
-	/* clean up the EAL */
-	rte_eal_cleanup();
-
-	return 0;
+	exit_cleanup();
 }
-- 
2.21.0


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

* Re: [PATCH] examples/multi_process: fix cleanup on exit
  2025-07-08  7:09 [PATCH] examples/multi_process: fix cleanup on exit Maayan Kashani
@ 2025-07-09 13:30 ` Burakov, Anatoly
  2025-07-09 14:40   ` Thomas Monjalon
  2025-07-09 15:01 ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Burakov, Anatoly @ 2025-07-09 13:30 UTC (permalink / raw)
  To: Maayan Kashani, dev; +Cc: rasland, stable

On 7/8/2025 9:09 AM, Maayan Kashani wrote:
> Device was started but not stopped on exit signal.
> Added port stop and close on exit.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

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

* Re: [PATCH] examples/multi_process: fix cleanup on exit
  2025-07-09 13:30 ` Burakov, Anatoly
@ 2025-07-09 14:40   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2025-07-09 14:40 UTC (permalink / raw)
  To: Maayan Kashani; +Cc: dev, rasland, stable, Burakov, Anatoly

09/07/2025 15:30, Burakov, Anatoly:
> On 7/8/2025 9:09 AM, Maayan Kashani wrote:
> > Device was started but not stopped on exit signal.
> > Added port stop and close on exit.
> > 
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
> > ---
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

There's always more cleanup and error handling we can do in examples.
As they are just code examples, I assume it does not have to be production-ready.

Applied, thanks.



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

* Re: [PATCH] examples/multi_process: fix cleanup on exit
  2025-07-08  7:09 [PATCH] examples/multi_process: fix cleanup on exit Maayan Kashani
  2025-07-09 13:30 ` Burakov, Anatoly
@ 2025-07-09 15:01 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2025-07-09 15:01 UTC (permalink / raw)
  To: Maayan Kashani; +Cc: dev, rasland, stable, Anatoly Burakov

On Tue, 8 Jul 2025 10:09:54 +0300
Maayan Kashani <mkashani@nvidia.com> wrote:

> +static void
> +exit_cleanup(void)
> +{
> +	unsigned int i;
> +
> +	RTE_LOG(INFO, APP, "Close ports.\n");
> +	for (i = 0; i < num_ports; i++) {
> +		if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +			if (rte_eth_dev_stop(ports[i]))
> +				rte_exit(EXIT_FAILURE, "Error stopping ports\n");
> +			if (rte_eth_dev_close(ports[i]))
> +				rte_exit(EXIT_FAILURE, "Error closing ports\n");
> +		}
> +	}

Could the ethdev cleanup be integrated into eal_cleanup() so applications
don't have to care?

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

end of thread, other threads:[~2025-07-09 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-08  7:09 [PATCH] examples/multi_process: fix cleanup on exit Maayan Kashani
2025-07-09 13:30 ` Burakov, Anatoly
2025-07-09 14:40   ` Thomas Monjalon
2025-07-09 15:01 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).