From 653dbcb18551a7833537672a55c793aaa20ad086 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 17 Dec 2019 17:30:25 -0500 Subject: [PATCH] lib/event: Make reactor structure public in SPDK internal Following the last patch, this is also a preparation to add reactor_get_stats RPC. Signed-off-by: Shuhei Matsumoto Change-Id: Ia6dc29f591f7112512be8a67b180b056150f467b Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/478025 Tested-by: SPDK CI Jenkins Community-CI: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Alexey Marchuk Reviewed-by: Jim Harris Reviewed-by: Paul Luse --- include/spdk_internal/event.h | 31 +++++++++++++++++++++++++++++++ lib/event/reactor.c | 30 ------------------------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index 9524bcb83..4ce25fed0 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -43,6 +43,7 @@ extern "C" { #include "spdk/event.h" #include "spdk/json.h" #include "spdk/thread.h" +#include "spdk/util.h" struct spdk_event { uint32_t lcore; @@ -51,6 +52,36 @@ struct spdk_event { void *arg2; }; +enum spdk_reactor_state { + SPDK_REACTOR_STATE_UNINITIALIZED = 0, + SPDK_REACTOR_STATE_INITIALIZED = 1, + SPDK_REACTOR_STATE_RUNNING = 2, + SPDK_REACTOR_STATE_EXITING = 3, + SPDK_REACTOR_STATE_SHUTDOWN = 4, +}; + +struct spdk_lw_thread { + TAILQ_ENTRY(spdk_lw_thread) link; +}; + +struct spdk_reactor { + /* Lightweight threads running on this reactor */ + TAILQ_HEAD(, spdk_lw_thread) threads; + + /* Logical core number for this reactor. */ + uint32_t lcore; + + struct { + uint32_t is_valid : 1; + uint32_t reserved : 31; + } flags; + + struct spdk_ring *events; + + /* The last known rusage values */ + struct rusage rusage; +} __attribute__((aligned(SPDK_CACHE_LINE_SIZE))); + int spdk_reactors_init(void); void spdk_reactors_fini(void); diff --git a/lib/event/reactor.c b/lib/event/reactor.c index a9cd98aef..5fc91d919 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -53,36 +53,6 @@ #define SPDK_EVENT_BATCH_SIZE 8 -enum spdk_reactor_state { - SPDK_REACTOR_STATE_UNINITIALIZED = 0, - SPDK_REACTOR_STATE_INITIALIZED = 1, - SPDK_REACTOR_STATE_RUNNING = 2, - SPDK_REACTOR_STATE_EXITING = 3, - SPDK_REACTOR_STATE_SHUTDOWN = 4, -}; - -struct spdk_lw_thread { - TAILQ_ENTRY(spdk_lw_thread) link; -}; - -struct spdk_reactor { - /* Lightweight threads running on this reactor */ - TAILQ_HEAD(, spdk_lw_thread) threads; - - /* Logical core number for this reactor. */ - uint32_t lcore; - - struct { - uint32_t is_valid : 1; - uint32_t reserved : 31; - } flags; - - struct spdk_ring *events; - - /* The last known rusage values */ - struct rusage rusage; -} __attribute__((aligned(SPDK_CACHE_LINE_SIZE))); - static struct spdk_reactor *g_reactors; static struct spdk_cpuset g_reactor_core_mask; static enum spdk_reactor_state g_reactor_state = SPDK_REACTOR_STATE_UNINITIALIZED;