SPDK Interrupt Mode: Improve processing of reactor interrupt mode.

spdk in interrupt, reactor dosen't correctly handle exited threads,
causing vhost threads still in reactor's lw_threads list. The fix
will do cleanup thread when it's state becomes EXITED. Though it's
exposed in v22.05.x, but the master branch also has the problem.

We will do this as below:

(1) When thread's state becomes SPDK_THREAD_STATE_EXITED, reactor
    process thread exits first.
(2) Then reactor do remove lw_thread and destroy it.

Fix issue: #2574

Signed-off-by: Apokleos <oliverliyn@gmail.com>
Change-Id: I3ac2681d70480563db3a0aee4aff61c2f272b140
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13706
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Apokleos 2022-07-22 03:07:36 +00:00 committed by Tomasz Zawadzki
parent a818564374
commit 89c1e5bfc0
2 changed files with 15 additions and 7 deletions

View File

@ -846,13 +846,6 @@ reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thre
{
struct spdk_thread *thread = spdk_thread_get_from_ctx(lw_thread);
if (spdk_unlikely(lw_thread->resched)) {
lw_thread->resched = false;
_reactor_remove_lw_thread(reactor, lw_thread);
_reactor_schedule_thread(thread);
return true;
}
if (spdk_unlikely(spdk_thread_is_exited(thread) &&
spdk_thread_is_idle(thread))) {
_reactor_remove_lw_thread(reactor, lw_thread);
@ -860,6 +853,13 @@ reactor_post_process_lw_thread(struct spdk_reactor *reactor, struct spdk_lw_thre
return true;
}
if (spdk_unlikely(lw_thread->resched)) {
lw_thread->resched = false;
_reactor_remove_lw_thread(reactor, lw_thread);
_reactor_schedule_thread(thread);
return true;
}
return false;
}

View File

@ -543,6 +543,9 @@ thread_exit(struct spdk_thread *thread, uint64_t now)
exited:
thread->state = SPDK_THREAD_STATE_EXITED;
if (spdk_unlikely(thread->in_interrupt)) {
g_thread_op_fn(thread, SPDK_THREAD_OP_RESCHED);
}
}
int
@ -1813,6 +1816,11 @@ _on_thread(void *ctx)
pthread_mutex_lock(&g_devlist_mutex);
ct->cur_thread = TAILQ_NEXT(ct->cur_thread, tailq);
while (ct->cur_thread && ct->cur_thread->state != SPDK_THREAD_STATE_RUNNING) {
SPDK_DEBUGLOG(thread, "thread %s is not running but still not destroyed.\n",
ct->cur_thread->name);
ct->cur_thread = TAILQ_NEXT(ct->cur_thread, tailq);
}
pthread_mutex_unlock(&g_devlist_mutex);
if (!ct->cur_thread) {