Commit de31e13f authored by siddhu-swarup's avatar siddhu-swarup Committed by Tomasz Zawadzki
Browse files

reactor: free call_reactor on app thread



spdk_app_stop() allocates struct call_reactor on the app thread.
the last worker reactor freed it,which threadsanitizer flags as a
data race. Route the final event through end_reactor() that executes
on th app core, calls the original completion, and frees the comtext.

Fixes: #3630.

Change-Id: I64676a3b16ce4be46e9a348ebb5cb8e03e3f3273
Signed-off-by: default avatarsiddhu-swarup <ialluraiah@msystechnologies.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25994


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
parent 52d23556
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ static struct spdk_governor *g_governor = NULL;

static int reactor_interrupt_init(struct spdk_reactor *reactor);
static void reactor_interrupt_fini(struct spdk_reactor *reactor);
static void end_reactor(void *arg1, void *arg2);

static pthread_mutex_t g_stopping_reactors_mtx = PTHREAD_MUTEX_INITIALIZER;
static bool g_stopping_reactors = false;
@@ -1403,8 +1404,7 @@ on_reactor(void *arg1, void *arg2)
	if (cr->cur_core >= g_reactor_count) {
		SPDK_DEBUGLOG(reactor, "Completed reactor iteration\n");

		evt = spdk_event_allocate(cr->orig_core, cr->cpl, cr->arg1, cr->arg2);
		free(cr);
		evt = spdk_event_allocate(cr->orig_core, end_reactor, cr, NULL);
	} else {
		SPDK_DEBUGLOG(reactor, "Continuing reactor iteration to %d\n",
			      cr->cur_core);
@@ -1415,6 +1415,17 @@ on_reactor(void *arg1, void *arg2)
	spdk_event_call(evt);
}

static void
end_reactor(void *arg1, void *arg2)
{
	struct call_reactor *cr = arg1;
	(void)arg2;

	cr->cpl(cr->arg1, cr->arg2);

	free(cr);
}

void
spdk_for_each_reactor(spdk_event_fn fn, void *arg1, void *arg2, spdk_event_fn cpl)
{