From 33ba56fef20a553a3386f86046ca81a4ca418836 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 13 Jan 2022 07:04:47 +0000 Subject: [PATCH] env_dpdk: ensure that cleanup destructor runs last The bdev fio plugin has a destructor function that cleans up the initialization thread, and we can't have it run after we've cleaned up DPDK or we get seg faults. The toolchains reserve priorities 1 to 100 for internal usage, meaning 101 is the highest usable priority level. We'll use this for the env_dpdk destructor priority, meaning it would be the last destructor to execute. Signed-off-by: Jim Harris Change-Id: I36718f9413267192d1c1dcec983a0f51b5d5b798 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11085 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Konrad Sztyber Reviewed-by: Dong Yi Tested-by: SPDK CI Jenkins --- lib/env_dpdk/init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 495684a4e..6b7e660ea 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -620,7 +620,12 @@ spdk_env_init(const struct spdk_env_opts *opts) return rc; } -__attribute__((destructor)) static void +/* We use priority 101 which is the highest priority level available + * to applications (the toolchains reserve 1 to 100 for internal usage). + * This ensures this destructor runs last, after any other destructors + * that might still need the environment up and running. + */ +__attribute__((destructor(101))) static void dpdk_cleanup(void) { /* Only call rte_eal_cleanup if the SPDK env library called rte_eal_init. */