diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 2e6161820..7820e9f67 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -473,9 +473,21 @@ static void _schedule_thread(void *arg1, void *arg2) { struct spdk_lw_thread *lw_thread = arg1; + struct spdk_thread *thread; + struct spdk_cpuset *cpumask; struct spdk_reactor *reactor; + uint32_t current_core; - reactor = spdk_reactor_get(spdk_env_get_current_core()); + current_core = spdk_env_get_current_core(); + + thread = spdk_thread_get_from_ctx(lw_thread); + cpumask = spdk_thread_get_cpumask(thread); + if (!spdk_cpuset_get_cpu(cpumask, current_core)) { + SPDK_ERRLOG("Thread was scheduled to the wrong core %d\n", current_core); + assert(false); + } + + reactor = spdk_reactor_get(current_core); assert(reactor != NULL); TAILQ_INSERT_TAIL(&reactor->threads, lw_thread, link);