diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index 6d9e830d4..a29d7bdad 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -142,4 +142,11 @@ const char *spdk_poller_state_str(enum spdk_poller_state state); const char *spdk_io_device_get_name(struct io_device *dev); +struct spdk_poller *spdk_thread_get_first_active_poller(struct spdk_thread *thread); +struct spdk_poller *spdk_thread_get_next_active_poller(struct spdk_poller *prev); +struct spdk_poller *spdk_thread_get_first_timed_poller(struct spdk_thread *thread); +struct spdk_poller *spdk_thread_get_next_timed_poller(struct spdk_poller *prev); +struct spdk_poller *spdk_thread_get_first_paused_poller(struct spdk_thread *thread); +struct spdk_poller *spdk_thread_get_next_paused_poller(struct spdk_poller *prev); + #endif /* SPDK_THREAD_INTERNAL_H_ */ diff --git a/lib/event/app_rpc.c b/lib/event/app_rpc.c index b07bda12f..c7dede5bc 100644 --- a/lib/event/app_rpc.c +++ b/lib/event/app_rpc.c @@ -202,13 +202,18 @@ _rpc_thread_get_stats(void *arg) uint64_t timed_pollers_count = 0; uint64_t paused_pollers_count = 0; - TAILQ_FOREACH(poller, &thread->active_pollers, tailq) { + for (poller = spdk_thread_get_first_active_poller(thread); poller != NULL; + poller = spdk_thread_get_next_active_poller(poller)) { active_pollers_count++; } - TAILQ_FOREACH(poller, &thread->timed_pollers, tailq) { + + for (poller = spdk_thread_get_first_timed_poller(thread); poller != NULL; + poller = spdk_thread_get_next_timed_poller(poller)) { timed_pollers_count++; } - TAILQ_FOREACH(poller, &thread->paused_pollers, tailq) { + + for (poller = spdk_thread_get_first_paused_poller(thread); poller != NULL; + poller = spdk_thread_get_next_paused_poller(poller)) { paused_pollers_count++; } @@ -268,19 +273,22 @@ _rpc_thread_get_pollers(void *arg) spdk_json_write_named_uint64(ctx->w, "id", spdk_thread_get_id(thread)); spdk_json_write_named_array_begin(ctx->w, "active_pollers"); - TAILQ_FOREACH(poller, &thread->active_pollers, tailq) { + for (poller = spdk_thread_get_first_active_poller(thread); poller != NULL; + poller = spdk_thread_get_next_active_poller(poller)) { rpc_get_poller(poller, ctx->w); } spdk_json_write_array_end(ctx->w); spdk_json_write_named_array_begin(ctx->w, "timed_pollers"); - TAILQ_FOREACH(poller, &thread->timed_pollers, tailq) { + for (poller = spdk_thread_get_first_timed_poller(thread); poller != NULL; + poller = spdk_thread_get_next_timed_poller(poller)) { rpc_get_poller(poller, ctx->w); } spdk_json_write_array_end(ctx->w); spdk_json_write_named_array_begin(ctx->w, "paused_pollers"); - TAILQ_FOREACH(poller, &thread->paused_pollers, tailq) { + for (poller = spdk_thread_get_first_paused_poller(thread); poller != NULL; + poller = spdk_thread_get_next_paused_poller(poller)) { rpc_get_poller(poller, ctx->w); } spdk_json_write_array_end(ctx->w); diff --git a/lib/thread/Makefile b/lib/thread/Makefile index de4a09d85..fdaebd081 100644 --- a/lib/thread/Makefile +++ b/lib/thread/Makefile @@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk SO_VER := 5 -SO_MINOR := 0 +SO_MINOR := 1 C_SRCS = thread.c LIBNAME = thread diff --git a/lib/thread/spdk_thread.map b/lib/thread/spdk_thread.map index 4f16fa7b8..0b0e3a952 100644 --- a/lib/thread/spdk_thread.map +++ b/lib/thread/spdk_thread.map @@ -59,6 +59,12 @@ # internal functions in spdk_internal/thread.h spdk_poller_state_str; spdk_io_device_get_name; + spdk_thread_get_first_active_poller; + spdk_thread_get_next_active_poller; + spdk_thread_get_first_timed_poller; + spdk_thread_get_next_timed_poller; + spdk_thread_get_first_paused_poller; + spdk_thread_get_next_paused_poller; local: *; }; diff --git a/lib/thread/thread.c b/lib/thread/thread.c index c42b77903..aa0c31983 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -1436,6 +1436,42 @@ spdk_poller_state_str(enum spdk_poller_state state) } } +struct spdk_poller * +spdk_thread_get_first_active_poller(struct spdk_thread *thread) +{ + return TAILQ_FIRST(&thread->active_pollers); +} + +struct spdk_poller * +spdk_thread_get_next_active_poller(struct spdk_poller *prev) +{ + return TAILQ_NEXT(prev, tailq); +} + +struct spdk_poller * +spdk_thread_get_first_timed_poller(struct spdk_thread *thread) +{ + return TAILQ_FIRST(&thread->active_pollers); +} + +struct spdk_poller * +spdk_thread_get_next_timed_poller(struct spdk_poller *prev) +{ + return TAILQ_NEXT(prev, tailq); +} + +struct spdk_poller * +spdk_thread_get_first_paused_poller(struct spdk_thread *thread) +{ + return TAILQ_FIRST(&thread->active_pollers); +} + +struct spdk_poller * +spdk_thread_get_next_paused_poller(struct spdk_poller *prev) +{ + return TAILQ_NEXT(prev, tailq); +} + struct call_thread { struct spdk_thread *cur_thread; spdk_msg_fn fn;