From f98ac63ea7bac017eabfec534b1479555dd4514b Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Fri, 30 Sep 2022 16:44:55 +0200 Subject: [PATCH] reactor: do not switch mode for threads in non interrupt tgt Fixes #2693 spdk threads should not be placed in interrupt mode if the application does not have interrupt mode enabled. This resulted in race condition, while reactor was placed in interrupt mode, thread was scheduled on it. Such operation is a valid one, but never should be attempt to change the threads mode in this case. Signed-off-by: Tomasz Zawadzki Change-Id: I10b0bbacac1df812badb91b37064528f66743e51 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14815 Reviewed-by: Michal Berger Reviewed-by: Jim Harris Reviewed-by: Ben Walker Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- lib/event/reactor.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 7c107a06f..7f7cf4741 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -364,10 +364,12 @@ _reactor_set_interrupt_mode(void *arg1, void *arg2) target->in_interrupt = target->new_in_interrupt; - /* Align spdk_thread with reactor to interrupt mode or poll mode */ - TAILQ_FOREACH_SAFE(lw_thread, &target->threads, link, tmp) { - thread = spdk_thread_get_from_ctx(lw_thread); - spdk_thread_send_msg(thread, _reactor_set_thread_interrupt_mode, target); + if (spdk_interrupt_mode_is_enabled()) { + /* Align spdk_thread with reactor to interrupt mode or poll mode */ + TAILQ_FOREACH_SAFE(lw_thread, &target->threads, link, tmp) { + thread = spdk_thread_get_from_ctx(lw_thread); + spdk_thread_send_msg(thread, _reactor_set_thread_interrupt_mode, target); + } } if (target->new_in_interrupt == false) {