examples/vdpa: fix devices cleanup

Message ID 20221226065105.2480103-1-yajunw@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series examples/vdpa: fix devices cleanup |

Checks

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

Commit Message

Yajun Wu Dec. 26, 2022, 6:51 a.m. UTC
  Move rte_eal_cleanup to function vdpa_sample_quit which
handling all example app quit.
Otherwise rte_eal_cleanup won't be called on receiving signal
like SIGINT(control + c).

Fixes: 10aa3757 ("examples: add eal cleanup to examples")
Cc: stable@dpdk.org

Signed-off-by: Yajun Wu <yajunw@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 examples/vdpa/main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Stephen Hemminger Dec. 26, 2022, 6:05 p.m. UTC | #1
On Mon, 26 Dec 2022 14:51:06 +0800
Yajun Wu <yajunw@nvidia.com> wrote:

> Move rte_eal_cleanup to function vdpa_sample_quit which
> handling all example app quit.
> Otherwise rte_eal_cleanup won't be called on receiving signal
> like SIGINT(control + c).
> 
> Fixes: 10aa3757 ("examples: add eal cleanup to examples")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yajun Wu <yajunw@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

NAK

rte_eal_cleanup is not signal safe.
This (and several other applications) are not managing termination
signals correctly. It is not safe to call many DPDK functions
from a signal handler. Imagine the case of getting SIGINT in
the middle of a driver holding a spin lock, then calling the
close function of that driver which then acquires the same lock.

The only safe way to handle signals is to set a flag
and do the shutdown and cleanup from the main loop.
  

Patch

diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
index 4c7e81d7b6..9149b66538 100644
--- a/examples/vdpa/main.c
+++ b/examples/vdpa/main.c
@@ -287,6 +287,8 @@  vdpa_sample_quit(void)
 		if (vports[i].ifname[0] != '\0')
 			close_vdpa(&vports[i]);
 	}
+	/* clean up the EAL */
+	rte_eal_cleanup();
 }
 
 static void
@@ -633,8 +635,5 @@  main(int argc, char *argv[])
 		vdpa_sample_quit();
 	}
 
-	/* clean up the EAL */
-	rte_eal_cleanup();
-
 	return 0;
 }