thread: In interrupt mode, exit thread by sending a message
Don't assume spdk_thread_poll() will ever get called. Instead, send a message to process the exit. Change-Id: Idd98e7e8164c5efebd0d7c9287e62731e7cbc998 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15551 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: John Levon <levon@movementarian.org>
This commit is contained in:
parent
5ecfb22192
commit
059073c4d9
@ -681,6 +681,8 @@ exited:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _thread_exit(void *ctx);
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_thread_exit(struct spdk_thread *thread)
|
spdk_thread_exit(struct spdk_thread *thread)
|
||||||
{
|
{
|
||||||
@ -698,6 +700,11 @@ spdk_thread_exit(struct spdk_thread *thread)
|
|||||||
thread->exit_timeout_tsc = spdk_get_ticks() + (spdk_get_ticks_hz() *
|
thread->exit_timeout_tsc = spdk_get_ticks() + (spdk_get_ticks_hz() *
|
||||||
SPDK_THREAD_EXIT_TIMEOUT_SEC);
|
SPDK_THREAD_EXIT_TIMEOUT_SEC);
|
||||||
thread->state = SPDK_THREAD_STATE_EXITING;
|
thread->state = SPDK_THREAD_STATE_EXITING;
|
||||||
|
|
||||||
|
if (spdk_interrupt_mode_is_enabled()) {
|
||||||
|
spdk_thread_send_msg(thread, _thread_exit, thread);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,6 +1129,16 @@ _thread_remove_pollers(void *ctx)
|
|||||||
thread->poller_unregistered = false;
|
thread->poller_unregistered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_thread_exit(void *ctx)
|
||||||
|
{
|
||||||
|
struct spdk_thread *thread = ctx;
|
||||||
|
|
||||||
|
assert(thread->state == SPDK_THREAD_STATE_EXITING);
|
||||||
|
|
||||||
|
thread_exit(thread, spdk_get_ticks());
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
||||||
{
|
{
|
||||||
@ -1144,16 +1161,15 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
|||||||
*/
|
*/
|
||||||
rc = thread_poll(thread, max_msgs, now);
|
rc = thread_poll(thread, max_msgs, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spdk_unlikely(thread->state == SPDK_THREAD_STATE_EXITING)) {
|
||||||
|
thread_exit(thread, now);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Non-block wait on thread's fd_group */
|
/* Non-block wait on thread's fd_group */
|
||||||
rc = spdk_fd_group_wait(thread->fgrp, 0);
|
rc = spdk_fd_group_wait(thread->fgrp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (spdk_unlikely(thread->state == SPDK_THREAD_STATE_EXITING)) {
|
|
||||||
thread_exit(thread, now);
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_update_stats(thread, spdk_get_ticks(), now, rc);
|
thread_update_stats(thread, spdk_get_ticks(), now, rc);
|
||||||
|
|
||||||
tls_thread = orig_thread;
|
tls_thread = orig_thread;
|
||||||
|
Loading…
Reference in New Issue
Block a user