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 <james.r.harris@intel.com>
Change-Id: I36718f9413267192d1c1dcec983a0f51b5d5b798
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11085
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2022-01-13 07:04:47 +00:00 committed by Tomasz Zawadzki
parent 31d684d759
commit af6fd29f93

View File

@ -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. */