lib/thread: Assert if spdk_poller_unregister() is called on wrong thread

Bdevperf tool had not called spdk_poller_unregister() called on the
same thread that called spdk_poller_register(). But it had not caused
any issue because spdk_poller_unregister() simply set the state to
unregistered. This design flaw has been fixed recently.

However the new pause feature has been added to poller and this
design flaw might cause any unexpected behavior if paused poller is
unregistered.

We do not know any other case such that spdk_poller_unregister()
is not called on the same thread that called spdk_poller_register(),
but we have no way to know it even if it exists. Hence let's add
assert for such cases.

Parsing poller lists managed by thread may be another option but
spdk_poller_unregister() is performance critical. So we do not check
list.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I9d91daaeb81fa33d5f042dbe7ddbd8ab6ea98d55
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479391
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-01-15 00:21:50 -05:00 committed by Jim Harris
parent 655e8e16e3
commit 6146c67856

View File

@ -111,6 +111,7 @@ struct spdk_poller {
uint64_t next_run_tick;
spdk_poller_fn fn;
void *arg;
struct spdk_thread *thread;
};
struct spdk_thread {
@ -789,6 +790,7 @@ spdk_poller_register(spdk_poller_fn fn,
poller->state = SPDK_POLLER_STATE_WAITING;
poller->fn = fn;
poller->arg = arg;
poller->thread = thread;
if (period_microseconds) {
quotient = period_microseconds / SPDK_SEC_TO_USEC;
@ -824,6 +826,12 @@ spdk_poller_unregister(struct spdk_poller **ppoller)
return;
}
if (poller->thread != thread) {
SPDK_ERRLOG("different from the thread that called spdk_poller_register()\n");
assert(false);
return;
}
/* If the poller was paused, put it on the active_pollers list so that
* its unregistration can be processed by spdk_thread_poll().
*/