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

lib/event: Use spdk_thread_lib_init_ext() to initialize thread library



Remove the prefix "spdk" from spdk_reactor_schedule_thread(), add
spdk_reactor_thread_op() and spdk_reactor_thread_op_supported().

For SPDK_THREAD_OP_NEW, spdk_reactor_thread_op() calls
_reactor_schedule_thread() and spdk_reactor_thread_op_supported()
returns true.

Then replace spdk_thread_lib_init() by spdk_thread_lib_init_ext()
with spdk_reactor_thread_op() and spdk_reactor_thread_op_supported().

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I232a3b2c6bcaf4d86b0dd3cefacd3e47eadda6d8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/968


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d82d6901
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -92,7 +92,8 @@ spdk_reactor_get(uint32_t lcore)
	return reactor;
}

static int spdk_reactor_schedule_thread(struct spdk_thread *thread);
static int spdk_reactor_thread_op(struct spdk_thread *thread, enum spdk_thread_op op);
static bool spdk_reactor_thread_op_supported(enum spdk_thread_op op);

int
spdk_reactors_init(void)
@@ -126,7 +127,8 @@ spdk_reactors_init(void)

	memset(g_reactors, 0, (last_core + 1) * sizeof(struct spdk_reactor));

	spdk_thread_lib_init(spdk_reactor_schedule_thread, sizeof(struct spdk_lw_thread));
	spdk_thread_lib_init_ext(spdk_reactor_thread_op, spdk_reactor_thread_op_supported,
				 sizeof(struct spdk_lw_thread));

	SPDK_ENV_FOREACH_CORE(i) {
		spdk_reactor_construct(&g_reactors[i], i);
@@ -474,7 +476,7 @@ _schedule_thread(void *arg1, void *arg2)
}

static int
spdk_reactor_schedule_thread(struct spdk_thread *thread)
_reactor_schedule_thread(struct spdk_thread *thread)
{
	uint32_t core;
	struct spdk_lw_thread *lw_thread;
@@ -514,6 +516,28 @@ spdk_reactor_schedule_thread(struct spdk_thread *thread)
	return 0;
}

static int
spdk_reactor_thread_op(struct spdk_thread *thread, enum spdk_thread_op op)
{
	switch (op) {
	case SPDK_THREAD_OP_NEW:
		return _reactor_schedule_thread(thread);
	default:
		return -ENOTSUP;
	}
}

static bool
spdk_reactor_thread_op_supported(enum spdk_thread_op op)
{
	switch (op) {
	case SPDK_THREAD_OP_NEW:
		return true;
	default:
		return false;
	}
}

struct call_reactor {
	uint32_t cur_core;
	spdk_event_fn fn;
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ test_schedule_thread(void)
	spdk_cpuset_set_cpu(&cpuset, 3, true);
	g_next_core = 4;

	/* spdk_reactor_schedule_thread() will be called in spdk_thread_create()
	/* _reactor_schedule_thread() will be called in spdk_thread_create()
	 * at its end because it is passed to SPDK thread library by
	 * spdk_thread_lib_init().
	 */