thread: Add SPDK internal APIs spdk_thread_get_first/next_active/timed/paused_poller()
The following patches will introduce red black tree to manage timed pollers efficiently but it will be based on macros available only in lib/thread/thread.c. Hence then it will be difficult to expose the internal of timed pollers tree outside the file. On the other hand, we do not want to include JSON into the file. Hence add a few SPDK internal APIs to iterate pollers list transparently. For spdk_thread_get_next_active/timed/pause_poller(), we omit the parameter thread and get it internally from poller->thread even if the names include the term "thread". This will be slightly cleaner. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I000801a2e4dc42fa79801a2fd6f2b06e1b769c88 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7717 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
d5b7f3c580
commit
cd83ea4a6d
@ -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_ */
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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: *;
|
||||
};
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user