lib/thread: Stop new poller and reap unregistering poller after thread is marked as exited
This is a preparation to support voluntary thread termination by calling spdk_thread_exit(). One of the subsequent patches will allow thread to exit only if all of its pollers are being unregistered. After the thread is marked as exited, only unregistering pollers will remain if the exited thread does not accept registering new poller. Hence in this patch, we change spdk_poller_register() to fail if the current thread is marked as exited first. Then, in subsequent patches, if we remove break from poller processing in spdk_thread_poll(), poller unregistration of the exited thread will complete, and we will be able to support voluntary thread termination easily by checking only the thread is exited and idle. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I5b843a07049ef01a5ff402eb521e294182ce2ae2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/822 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
13595495a1
commit
1e98e82051
@ -512,10 +512,6 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
||||
active_pollers_head, tailq, tmp) {
|
||||
int poller_rc;
|
||||
|
||||
if (thread->exit) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
|
||||
TAILQ_REMOVE(&thread->active_pollers, poller, tailq);
|
||||
free(poller);
|
||||
@ -551,10 +547,6 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
|
||||
TAILQ_FOREACH_SAFE(poller, &thread->timed_pollers, tailq, tmp) {
|
||||
int timer_rc = 0;
|
||||
|
||||
if (thread->exit) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
|
||||
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
|
||||
free(poller);
|
||||
@ -778,6 +770,11 @@ spdk_poller_register(spdk_poller_fn fn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (spdk_unlikely(thread->exit)) {
|
||||
SPDK_ERRLOG("thread %s is marked as exited\n", thread->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
poller = calloc(1, sizeof(*poller));
|
||||
if (poller == NULL) {
|
||||
SPDK_ERRLOG("Poller memory allocation failed\n");
|
||||
|
Loading…
Reference in New Issue
Block a user