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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I232a3b2c6bcaf4d86b0dd3cefacd3e47eadda6d8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/968
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-02-23 17:43:09 -05:00 committed by Tomasz Zawadzki
parent d82d69017f
commit 1368aec870
2 changed files with 28 additions and 4 deletions

View File

@ -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;

View File

@ -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().
*/