thread: use spdk_thread_get_app_thread instead of _spdk_get_app_thread
Signed-off-by: Ziv Hirsch <zivhirsch13@gmail.com> Change-Id: I68754dcd9c87e9f9a595f134de345d42e7d09e70 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16783 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
652db802f1
commit
a67da4e64c
@ -128,13 +128,6 @@ void spdk_for_each_reactor(spdk_event_fn fn, void *arg1, void *arg2, spdk_event_
|
||||
int spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt,
|
||||
spdk_reactor_set_interrupt_mode_cb cb_fn, void *cb_arg);
|
||||
|
||||
/**
|
||||
* Get a handle to spdk application thread.
|
||||
*
|
||||
* \return a pointer to spdk application thread on success or NULL on failure.
|
||||
*/
|
||||
struct spdk_thread *_spdk_get_app_thread(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -47,7 +47,6 @@ struct spdk_app {
|
||||
static struct spdk_app g_spdk_app;
|
||||
static spdk_msg_fn g_start_fn = NULL;
|
||||
static void *g_start_arg = NULL;
|
||||
static struct spdk_thread *g_app_thread = NULL;
|
||||
static bool g_delay_subsystem_init = false;
|
||||
static bool g_shutdown_sig_received = false;
|
||||
static char *g_executable_name;
|
||||
@ -146,7 +145,7 @@ app_start_shutdown(void *ctx)
|
||||
void
|
||||
spdk_app_start_shutdown(void)
|
||||
{
|
||||
spdk_thread_send_critical_msg(g_app_thread, app_start_shutdown);
|
||||
spdk_thread_send_critical_msg(spdk_thread_get_app_thread(), app_start_shutdown);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -259,7 +258,7 @@ app_setup_signal_handlers(struct spdk_app_opts *opts)
|
||||
static void
|
||||
app_start_application(void)
|
||||
{
|
||||
assert(spdk_get_thread() == g_app_thread);
|
||||
assert(spdk_get_thread() == spdk_thread_get_app_thread());
|
||||
|
||||
g_start_fn(g_start_arg);
|
||||
}
|
||||
@ -718,10 +717,9 @@ spdk_app_start(struct spdk_app_opts *opts_user, spdk_msg_fn start_fn,
|
||||
|
||||
spdk_cpuset_set_cpu(&tmp_cpumask, spdk_env_get_current_core(), true);
|
||||
|
||||
/* Now that the reactors have been initialized, we can create an
|
||||
* initialization thread. */
|
||||
g_app_thread = spdk_thread_create("app_thread", &tmp_cpumask);
|
||||
if (!g_app_thread) {
|
||||
/* Now that the reactors have been initialized, we can create the app thread. */
|
||||
spdk_thread_create("app_thread", &tmp_cpumask);
|
||||
if (!spdk_thread_get_app_thread()) {
|
||||
SPDK_ERRLOG("Unable to create an spdk_thread for initialization\n");
|
||||
return 1;
|
||||
}
|
||||
@ -748,7 +746,7 @@ spdk_app_start(struct spdk_app_opts *opts_user, spdk_msg_fn start_fn,
|
||||
g_start_fn = start_fn;
|
||||
g_start_arg = arg1;
|
||||
|
||||
spdk_thread_send_msg(g_app_thread, bootstrap_fn, NULL);
|
||||
spdk_thread_send_msg(spdk_thread_get_app_thread(), bootstrap_fn, NULL);
|
||||
|
||||
/* This blocks until spdk_app_stop is called */
|
||||
spdk_reactors_start();
|
||||
@ -772,7 +770,7 @@ static void
|
||||
_start_subsystem_fini(void *arg1)
|
||||
{
|
||||
if (g_scheduling_in_progress) {
|
||||
spdk_thread_send_msg(g_app_thread, _start_subsystem_fini, NULL);
|
||||
spdk_thread_send_msg(spdk_thread_get_app_thread(), _start_subsystem_fini, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -823,13 +821,7 @@ spdk_app_stop(int rc)
|
||||
* We want to run spdk_subsystem_fini() from the same thread where spdk_subsystem_init()
|
||||
* was called.
|
||||
*/
|
||||
spdk_thread_send_msg(g_app_thread, app_stop, (void *)(intptr_t)rc);
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
_spdk_get_app_thread(void)
|
||||
{
|
||||
return g_app_thread;
|
||||
spdk_thread_send_msg(spdk_thread_get_app_thread(), app_stop, (void *)(intptr_t)rc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1209,7 +1201,7 @@ rpc_framework_start_init_cpl(int rc, void *arg1)
|
||||
{
|
||||
struct spdk_jsonrpc_request *request = arg1;
|
||||
|
||||
assert(spdk_get_thread() == g_app_thread);
|
||||
assert(spdk_get_thread() == spdk_thread_get_app_thread());
|
||||
|
||||
if (rc) {
|
||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
||||
|
@ -334,7 +334,7 @@ _reactor_set_notify_cpuset_cpl(void *arg1, void *arg2)
|
||||
|
||||
if (target->new_in_interrupt == false) {
|
||||
target->set_interrupt_mode_in_progress = false;
|
||||
spdk_thread_send_msg(_spdk_get_app_thread(), target->set_interrupt_mode_cb_fn,
|
||||
spdk_thread_send_msg(spdk_thread_get_app_thread(), target->set_interrupt_mode_cb_fn,
|
||||
target->set_interrupt_mode_cb_arg);
|
||||
} else {
|
||||
_event_call(target->lcore, _reactor_set_interrupt_mode, target, NULL);
|
||||
@ -392,7 +392,7 @@ _reactor_set_interrupt_mode(void *arg1, void *arg2)
|
||||
}
|
||||
|
||||
target->set_interrupt_mode_in_progress = false;
|
||||
spdk_thread_send_msg(_spdk_get_app_thread(), target->set_interrupt_mode_cb_fn,
|
||||
spdk_thread_send_msg(spdk_thread_get_app_thread(), target->set_interrupt_mode_cb_fn,
|
||||
target->set_interrupt_mode_cb_arg);
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,7 @@ spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (spdk_get_thread() != _spdk_get_app_thread()) {
|
||||
if (spdk_get_thread() != spdk_thread_get_app_thread()) {
|
||||
SPDK_ERRLOG("It is only permitted within spdk application thread.\n");
|
||||
return -EPERM;
|
||||
}
|
||||
|
@ -13,22 +13,6 @@
|
||||
#include "event/scheduler_static.c"
|
||||
#include "../module/scheduler/dynamic/scheduler_dynamic.c"
|
||||
|
||||
struct spdk_thread *
|
||||
_spdk_get_app_thread(void)
|
||||
{
|
||||
struct spdk_lw_thread *lw_thread;
|
||||
struct spdk_thread *thread;
|
||||
|
||||
/* Assume there has to be at least one thread on main
|
||||
* reactor, that has at least one thread. */
|
||||
lw_thread = TAILQ_FIRST(&g_scheduling_reactor->threads);
|
||||
SPDK_CU_ASSERT_FATAL(lw_thread != NULL);
|
||||
thread = spdk_thread_get_from_ctx(lw_thread);
|
||||
SPDK_CU_ASSERT_FATAL(thread != NULL);
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
static void
|
||||
test_create_reactor(void)
|
||||
{
|
||||
@ -508,7 +492,7 @@ static uint32_t
|
||||
_run_events_till_completion(uint32_t reactor_count)
|
||||
{
|
||||
struct spdk_reactor *reactor;
|
||||
struct spdk_thread *app_thread = _spdk_get_app_thread();
|
||||
struct spdk_thread *app_thread = spdk_thread_get_app_thread();
|
||||
uint32_t i, events;
|
||||
uint32_t total_events = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user