Commit a9430856 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent bda55ddb
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -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