Commit 3f2c8979 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Tomasz Zawadzki
Browse files

event: switch reactors to poll mode before stopping



When stopping a reactor in interrupt mode it can hang waiting for an
event that will not arrive, preventing shutdown.

Fixes #3340

Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Change-Id: Ic078f1876ac998ae21c3d2ee9628e732a3a6e9b4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22878


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 443e1ea3
Loading
Loading
Loading
Loading
+31 −6
Original line number Diff line number Diff line
@@ -997,14 +997,11 @@ reactor_run(void *arg)
				_reactor_remove_lw_thread(reactor, lw_thread);
				spdk_thread_destroy(thread);
			} else {
				if (spdk_unlikely(reactor->in_interrupt)) {
					reactor_interrupt_run(reactor);
				} else {
				assert(!reactor->in_interrupt);
				spdk_thread_poll(thread, 0, 0);
			}
		}
	}
	}

	return 0;
}
@@ -1106,10 +1103,38 @@ nop(void *arg1, void *arg2)
{
}

static void
_reactors_stop_disable_interrupt(void *ctx)
{
	struct spdk_reactor *reactor = ctx;
	uint32_t lcore;
	int rc;

	if (reactor == NULL) {
		lcore = spdk_env_get_first_core();
	} else {
		lcore = spdk_env_get_next_core(reactor->lcore);
	}

	while (lcore < SPDK_ENV_LCORE_ID_ANY) {
		reactor = spdk_reactor_get(lcore);
		assert(reactor != NULL);
		if (reactor->in_interrupt) {
			rc = spdk_reactor_set_interrupt_mode(lcore, false, _reactors_stop_disable_interrupt, reactor);
			if (rc == 0) {
				return;
			}
		}
		lcore = spdk_env_get_next_core(lcore);
	}

	spdk_for_each_reactor(nop, NULL, NULL, _reactors_stop);
}

void
spdk_reactors_stop(void *arg1)
{
	spdk_for_each_reactor(nop, NULL, NULL, _reactors_stop);
	_reactors_stop_disable_interrupt(NULL);
}

static pthread_mutex_t g_scheduler_mtx = PTHREAD_MUTEX_INITIALIZER;