From 1c297d7e30ff781dc6631180f00167cdeb447457 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Sun, 7 Apr 2019 11:10:49 +0200 Subject: [PATCH] thread: fix crash on non-contiguous cpu range in cpumask Limit the thread scheduler to put spdk_threads on lcores < last_lcore instead of lcores < lcore_count, which was probably the original intent. When the cpumask was not a contiguous cpu range, the thread scheduler failed to schedule any spdk_threads on the last cores. There was one hardcoded thread created for each reactor, but the scheduler could squash some of those into a single reactor. This broke the legacy lcore-based messages as those expect there to be at least one spdk_thread per lcore. Any spdk_poller_register() or spdk_get_io_channel() called from such a legacy message would fail an assertion, as spdk_get_thread() returned NULL. Fixes #743 Change-Id: I81a3f76d9c4788596c697df6ff51b264b99ce10b Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450353 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Karol Latecki Reviewed-by: Jim Harris --- lib/event/reactor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 62702402f..7c337f4d0 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -371,7 +371,7 @@ spdk_reactor_schedule_thread(struct spdk_thread *thread) memset(lw_thread, 0, sizeof(*lw_thread)); pthread_mutex_lock(&g_scheduler_mtx); - if (g_next_core > spdk_env_get_core_count()) { + if (g_next_core > spdk_env_get_last_core()) { g_next_core = spdk_env_get_first_core(); } core = g_next_core;