From a9430856b62453a0b2f775f860c7f5539ce43638 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 20 May 2020 07:29:58 +0900 Subject: [PATCH] example/nvmf: Deprecate spdk_thread_lib_init() by spdk_thread_lib_init_ext() Replace spdk_thread_lib_init() by spdk_thread_lib_init_ext() to support dynamic SPDK thread scheduling in this sample application. Add nvmf_reactor_thread_op() and nvmf_reactor_thread_op_supported(), and then pass them by spdk_thread_lib_init_ext(). Signed-off-by: Shuhei Matsumoto Change-Id: I9498d45d74757d8893b2b415fe28bf65f8fd02d6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2540 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- examples/nvmf/nvmf/nvmf.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/examples/nvmf/nvmf/nvmf.c b/examples/nvmf/nvmf/nvmf.c index 3327e67ac1..c7841f1a81 100644 --- a/examples/nvmf/nvmf/nvmf.c +++ b/examples/nvmf/nvmf/nvmf.c @@ -278,6 +278,30 @@ nvmf_schedule_spdk_thread(struct spdk_thread *thread) return 0; } +static int +nvmf_reactor_thread_op(struct spdk_thread *thread, enum spdk_thread_op op) +{ + switch (op) { + case SPDK_THREAD_OP_NEW: + return nvmf_schedule_spdk_thread(thread); + case SPDK_THREAD_OP_RESCHED: + default: + return -ENOTSUP; + } +} + +static bool +nvmf_reactor_thread_op_supported(enum spdk_thread_op op) +{ + switch (op) { + case SPDK_THREAD_OP_NEW: + return true; + case SPDK_THREAD_OP_RESCHED: + default: + return false; + } +} + static int nvmf_init_threads(void) { @@ -295,7 +319,8 @@ nvmf_init_threads(void) * SPDK optionally allocates extra memory to be used by the application * framework. The size of the extra memory allocated is the second parameter. */ - spdk_thread_lib_init(nvmf_schedule_spdk_thread, sizeof(struct nvmf_lw_thread)); + spdk_thread_lib_init_ext(nvmf_reactor_thread_op, nvmf_reactor_thread_op_supported, + sizeof(struct nvmf_lw_thread)); /* Spawn one system thread per CPU core. The system thread is called a reactor. * SPDK will spawn lightweight threads that must be mapped to reactors in