From ba8515c61c7b3cdaac1ffa970d3aa57b7fa03aca Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 5 Oct 2017 16:02:49 +0200 Subject: [PATCH] vhost: allocate session_shutdown as spdk_event instead of pthread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change allows for spdk_app_stop() to be executed on a DPDK lcore instead outside of DPDK lcore range. This is preparation for SPDK asynchronous finish, to assure calling spdk_app_stop() from master core. Signed-off-by: Tomasz Zawadzki Change-Id: Iedc878346c74296b105f93507b2c858aedfbf16e Reviewed-on: https://review.gerrithub.io/381535 Tested-by: SPDK Automated Test System Reviewed-by: Maciej Szwed Reviewed-by: Pawel Wodkowski Reviewed-by: Piotr Pelpliński Reviewed-by: Jim Harris --- lib/vhost/vhost.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index deebe94e9..a63b745bc 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -810,6 +810,12 @@ spdk_vhost_startup(void *arg1, void *arg2) } } +static void +session_app_stop(void *arg1, void *arg2) +{ + spdk_app_stop(0); +} + static void * session_shutdown(void *arg) { @@ -834,7 +840,7 @@ session_shutdown(void *arg) } SPDK_NOTICELOG("Exiting\n"); - spdk_app_stop(0); + spdk_event_call((struct spdk_event *)arg); return NULL; } @@ -846,8 +852,11 @@ spdk_vhost_shutdown_cb(void) { pthread_t tid; char buf[64]; + struct spdk_event *vhost_app_stop; - if (pthread_create(&tid, NULL, &session_shutdown, NULL) < 0) { + vhost_app_stop = spdk_event_allocate(spdk_env_get_current_core(), session_app_stop, NULL, NULL); + + if (pthread_create(&tid, NULL, &session_shutdown, vhost_app_stop) < 0) { spdk_strerror_r(errno, buf, sizeof(buf)); SPDK_ERRLOG("Failed to start session shutdown thread (%d): %s\n", errno, buf); abort();