From b514849ca15b498b5e198c11c21084858a860c82 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 13 Jan 2022 12:31:09 +0100 Subject: [PATCH] lib/vhost: move vhost_user init thread tracking Keep track of g_vhost_user_init_thread, local to the rte_vhost_user.c. There is no need to track this in generic vhost layer. Signed-off-by: Tomasz Zawadzki Change-Id: I1fd22e196a3091284f5f9c3c0c7c70a0e18514cb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11075 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker --- lib/vhost/rte_vhost_user.c | 9 +++++++-- lib/vhost/vhost.c | 8 -------- lib/vhost/vhost_internal.h | 3 --- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/vhost/rte_vhost_user.c b/lib/vhost/rte_vhost_user.c index a6a94fd2b..80a17d3ed 100644 --- a/lib/vhost/rte_vhost_user.c +++ b/lib/vhost/rte_vhost_user.c @@ -49,6 +49,8 @@ /* Path to folder where character device will be created. Can be set by user. */ static char g_vhost_user_dev_dirname[PATH_MAX] = ""; +static struct spdk_thread *g_vhost_user_init_thread; + /** * DPDK calls our callbacks synchronously but the work those callbacks * perform needs to be async. Luckily, all DPDK callbacks are called on @@ -618,7 +620,7 @@ foreach_session(void *arg1) out: spdk_vhost_unlock(); - spdk_thread_send_msg(g_vhost_init_thread, foreach_session_finish_cb, arg1); + spdk_thread_send_msg(g_vhost_user_init_thread, foreach_session_finish_cb, arg1); } void @@ -1120,6 +1122,9 @@ vhost_user_init(void) g_vhost_user_started = true; + g_vhost_user_init_thread = spdk_get_thread(); + assert(g_vhost_user_init_thread != NULL); + return 0; } @@ -1144,7 +1149,7 @@ vhost_user_session_shutdown(void *arg) } SPDK_INFOLOG(vhost, "Exiting\n"); - spdk_thread_send_msg(g_vhost_init_thread, vhost_cb, NULL); + spdk_thread_send_msg(g_vhost_user_init_thread, vhost_cb, NULL); return NULL; } diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index eec6c3046..55220541b 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -46,9 +46,6 @@ bool g_packed_ring_recovery = false; static struct spdk_cpuset g_vhost_core_mask; -/* Thread performing all vhost management operations */ -struct spdk_thread *g_vhost_init_thread = NULL; - static TAILQ_HEAD(, spdk_vhost_dev) g_vhost_devices = TAILQ_HEAD_INITIALIZER( g_vhost_devices); static pthread_mutex_t g_vhost_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -908,9 +905,6 @@ spdk_vhost_init(spdk_vhost_init_cb init_cb) uint32_t i; int ret = 0; - g_vhost_init_thread = spdk_get_thread(); - assert(g_vhost_init_thread != NULL); - ret = vhost_user_init(); if (ret != 0) { init_cb(ret); @@ -947,8 +941,6 @@ vhost_fini(void *arg1) void spdk_vhost_fini(spdk_vhost_fini_cb fini_cb) { - assert(spdk_get_thread() == g_vhost_init_thread); - g_fini_cb = fini_cb; vhost_user_fini(vhost_fini); diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index 2397a4b0f..32f9c7316 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -47,9 +47,6 @@ extern bool g_packed_ring_recovery; -/* Thread performing all vhost management operations */ -extern struct spdk_thread *g_vhost_init_thread; - #define SPDK_VHOST_MAX_VQUEUES 256 #define SPDK_VHOST_MAX_VQ_SIZE 1024