From 54bc83dcc7abf940817f96badf5c6177dc9812f1 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 12 May 2021 13:40:47 +0900 Subject: [PATCH] thread: Make struct spdk_thread and enum spdk_thread_state private in thread.c Move the definition of struct spdk_thread and enum spdk_thread_state from include/spdk_internal/thread.h to lib/thread/thread.c. Signed-off-by: Shuhei Matsumoto Change-Id: Iab8cec9776e76668ebfb3c75064c316d10607421 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7802 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- include/spdk_internal/thread.h | 59 +--------------------------------- lib/thread/thread.c | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index 98fe1ee2a..1fd654800 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -37,8 +37,6 @@ #include "spdk/stdinc.h" #include "spdk/thread.h" -#define SPDK_MAX_THREAD_NAME_LEN 256 - struct spdk_poller; struct spdk_poller_stats { @@ -46,62 +44,7 @@ struct spdk_poller_stats { uint64_t busy_count; }; -enum spdk_thread_state { - /* The thread is pocessing poller and message by spdk_thread_poll(). */ - SPDK_THREAD_STATE_RUNNING, - - /* The thread is in the process of termination. It reaps unregistering - * poller are releasing I/O channel. - */ - SPDK_THREAD_STATE_EXITING, - - /* The thread is exited. It is ready to call spdk_thread_destroy(). */ - SPDK_THREAD_STATE_EXITED, -}; - -struct spdk_thread { - uint64_t tsc_last; - struct spdk_thread_stats stats; - /* - * Contains pollers actively running on this thread. Pollers - * are run round-robin. The thread takes one poller from the head - * of the ring, executes it, then puts it back at the tail of - * the ring. - */ - TAILQ_HEAD(active_pollers_head, spdk_poller) active_pollers; - /** - * Contains pollers running on this thread with a periodic timer. - */ - TAILQ_HEAD(timed_pollers_head, spdk_poller) timed_pollers; - /* - * Contains paused pollers. Pollers on this queue are waiting until - * they are resumed (in which case they're put onto the active/timer - * queues) or unregistered. - */ - TAILQ_HEAD(paused_pollers_head, spdk_poller) paused_pollers; - struct spdk_ring *messages; - int msg_fd; - SLIST_HEAD(, spdk_msg) msg_cache; - size_t msg_cache_count; - spdk_msg_fn critical_msg; - uint64_t id; - enum spdk_thread_state state; - int pending_unregister_count; - - TAILQ_HEAD(, spdk_io_channel) io_channels; - TAILQ_ENTRY(spdk_thread) tailq; - - char name[SPDK_MAX_THREAD_NAME_LEN + 1]; - struct spdk_cpuset cpumask; - uint64_t exit_timeout_tsc; - - /* Indicates whether this spdk_thread currently runs in interrupt. */ - bool in_interrupt; - struct spdk_fd_group *fgrp; - - /* User context allocated at the end */ - uint8_t ctx[0]; -}; +struct spdk_thread; const char *spdk_poller_get_name(struct spdk_poller *poller); const char *spdk_poller_get_state_str(struct spdk_poller *poller); diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 48950bac1..8184cc2f4 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -53,6 +53,7 @@ #define SPDK_MAX_DEVICE_NAME_LEN 256 #define SPDK_THREAD_EXIT_TIMEOUT_SEC 5 #define SPDK_MAX_POLLER_NAME_LEN 256 +#define SPDK_MAX_THREAD_NAME_LEN 256 enum spdk_poller_state { /* The poller is registered with a thread but not currently executing its fn. */ @@ -95,6 +96,63 @@ struct spdk_poller { char name[SPDK_MAX_POLLER_NAME_LEN + 1]; }; +enum spdk_thread_state { + /* The thread is pocessing poller and message by spdk_thread_poll(). */ + SPDK_THREAD_STATE_RUNNING, + + /* The thread is in the process of termination. It reaps unregistering + * poller are releasing I/O channel. + */ + SPDK_THREAD_STATE_EXITING, + + /* The thread is exited. It is ready to call spdk_thread_destroy(). */ + SPDK_THREAD_STATE_EXITED, +}; + +struct spdk_thread { + uint64_t tsc_last; + struct spdk_thread_stats stats; + /* + * Contains pollers actively running on this thread. Pollers + * are run round-robin. The thread takes one poller from the head + * of the ring, executes it, then puts it back at the tail of + * the ring. + */ + TAILQ_HEAD(active_pollers_head, spdk_poller) active_pollers; + /** + * Contains pollers running on this thread with a periodic timer. + */ + TAILQ_HEAD(timed_pollers_head, spdk_poller) timed_pollers; + /* + * Contains paused pollers. Pollers on this queue are waiting until + * they are resumed (in which case they're put onto the active/timer + * queues) or unregistered. + */ + TAILQ_HEAD(paused_pollers_head, spdk_poller) paused_pollers; + struct spdk_ring *messages; + int msg_fd; + SLIST_HEAD(, spdk_msg) msg_cache; + size_t msg_cache_count; + spdk_msg_fn critical_msg; + uint64_t id; + enum spdk_thread_state state; + int pending_unregister_count; + + TAILQ_HEAD(, spdk_io_channel) io_channels; + TAILQ_ENTRY(spdk_thread) tailq; + + char name[SPDK_MAX_THREAD_NAME_LEN + 1]; + struct spdk_cpuset cpumask; + uint64_t exit_timeout_tsc; + + /* Indicates whether this spdk_thread currently runs in interrupt. */ + bool in_interrupt; + struct spdk_fd_group *fgrp; + + /* User context allocated at the end */ + uint8_t ctx[0]; +}; + static pthread_mutex_t g_devlist_mutex = PTHREAD_MUTEX_INITIALIZER; static spdk_new_thread_fn g_new_thread_fn = NULL;