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,
|
int spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt,
|
||||||
spdk_reactor_set_interrupt_mode_cb cb_fn, void *cb_arg);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,7 +47,6 @@ struct spdk_app {
|
|||||||
static struct spdk_app g_spdk_app;
|
static struct spdk_app g_spdk_app;
|
||||||
static spdk_msg_fn g_start_fn = NULL;
|
static spdk_msg_fn g_start_fn = NULL;
|
||||||
static void *g_start_arg = 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_delay_subsystem_init = false;
|
||||||
static bool g_shutdown_sig_received = false;
|
static bool g_shutdown_sig_received = false;
|
||||||
static char *g_executable_name;
|
static char *g_executable_name;
|
||||||
@ -146,7 +145,7 @@ app_start_shutdown(void *ctx)
|
|||||||
void
|
void
|
||||||
spdk_app_start_shutdown(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
|
static void
|
||||||
@ -259,7 +258,7 @@ app_setup_signal_handlers(struct spdk_app_opts *opts)
|
|||||||
static void
|
static void
|
||||||
app_start_application(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);
|
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);
|
spdk_cpuset_set_cpu(&tmp_cpumask, spdk_env_get_current_core(), true);
|
||||||
|
|
||||||
/* Now that the reactors have been initialized, we can create an
|
/* Now that the reactors have been initialized, we can create the app thread. */
|
||||||
* initialization thread. */
|
spdk_thread_create("app_thread", &tmp_cpumask);
|
||||||
g_app_thread = spdk_thread_create("app_thread", &tmp_cpumask);
|
if (!spdk_thread_get_app_thread()) {
|
||||||
if (!g_app_thread) {
|
|
||||||
SPDK_ERRLOG("Unable to create an spdk_thread for initialization\n");
|
SPDK_ERRLOG("Unable to create an spdk_thread for initialization\n");
|
||||||
return 1;
|
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_fn = start_fn;
|
||||||
g_start_arg = arg1;
|
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 */
|
/* This blocks until spdk_app_stop is called */
|
||||||
spdk_reactors_start();
|
spdk_reactors_start();
|
||||||
@ -772,7 +770,7 @@ static void
|
|||||||
_start_subsystem_fini(void *arg1)
|
_start_subsystem_fini(void *arg1)
|
||||||
{
|
{
|
||||||
if (g_scheduling_in_progress) {
|
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;
|
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()
|
* We want to run spdk_subsystem_fini() from the same thread where spdk_subsystem_init()
|
||||||
* was called.
|
* was called.
|
||||||
*/
|
*/
|
||||||
spdk_thread_send_msg(g_app_thread, app_stop, (void *)(intptr_t)rc);
|
spdk_thread_send_msg(spdk_thread_get_app_thread(), app_stop, (void *)(intptr_t)rc);
|
||||||
}
|
|
||||||
|
|
||||||
struct spdk_thread *
|
|
||||||
_spdk_get_app_thread(void)
|
|
||||||
{
|
|
||||||
return g_app_thread;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1209,7 +1201,7 @@ rpc_framework_start_init_cpl(int rc, void *arg1)
|
|||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = 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) {
|
if (rc) {
|
||||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
|
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) {
|
if (target->new_in_interrupt == false) {
|
||||||
target->set_interrupt_mode_in_progress = 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);
|
target->set_interrupt_mode_cb_arg);
|
||||||
} else {
|
} else {
|
||||||
_event_call(target->lcore, _reactor_set_interrupt_mode, target, NULL);
|
_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;
|
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);
|
target->set_interrupt_mode_cb_arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt,
|
|||||||
return -ENOTSUP;
|
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");
|
SPDK_ERRLOG("It is only permitted within spdk application thread.\n");
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
@ -13,22 +13,6 @@
|
|||||||
#include "event/scheduler_static.c"
|
#include "event/scheduler_static.c"
|
||||||
#include "../module/scheduler/dynamic/scheduler_dynamic.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
|
static void
|
||||||
test_create_reactor(void)
|
test_create_reactor(void)
|
||||||
{
|
{
|
||||||
@ -508,7 +492,7 @@ static uint32_t
|
|||||||
_run_events_till_completion(uint32_t reactor_count)
|
_run_events_till_completion(uint32_t reactor_count)
|
||||||
{
|
{
|
||||||
struct spdk_reactor *reactor;
|
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 i, events;
|
||||||
uint32_t total_events = 0;
|
uint32_t total_events = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user