diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 7c30f17f46..2e272fec97 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -1310,6 +1310,7 @@ Example response: "timed_pollers": [ { "name": "spdk_rpc_subsystem_poll", + "id": 1, "state": "waiting", "run_count": 12345, "busy_count": 10000, diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index 752d45dd49..be2914790f 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -48,6 +48,7 @@ struct io_device; struct spdk_thread; const char *spdk_poller_get_name(struct spdk_poller *poller); +uint64_t spdk_poller_get_id(struct spdk_poller *poller); const char *spdk_poller_get_state_str(struct spdk_poller *poller); uint64_t spdk_poller_get_period_ticks(struct spdk_poller *poller); void spdk_poller_get_stats(struct spdk_poller *poller, struct spdk_poller_stats *stats); diff --git a/lib/event/app_rpc.c b/lib/event/app_rpc.c index 883c86abb4..3f7db6fd64 100644 --- a/lib/event/app_rpc.c +++ b/lib/event/app_rpc.c @@ -261,6 +261,7 @@ rpc_get_poller(struct spdk_poller *poller, struct spdk_json_write_ctx *w) spdk_json_write_object_begin(w); spdk_json_write_named_string(w, "name", spdk_poller_get_name(poller)); + spdk_json_write_named_uint64(w, "id", spdk_poller_get_id(poller)); spdk_json_write_named_string(w, "state", spdk_poller_get_state_str(poller)); spdk_json_write_named_uint64(w, "run_count", stats.run_count); spdk_json_write_named_uint64(w, "busy_count", stats.busy_count); diff --git a/lib/thread/Makefile b/lib/thread/Makefile index 846b32f529..4848334098 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 := 6 -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 94b5c5e6b0..672f2183ef 100644 --- a/lib/thread/spdk_thread.map +++ b/lib/thread/spdk_thread.map @@ -58,6 +58,7 @@ # internal functions in spdk_internal/thread.h spdk_poller_get_name; + spdk_poller_get_id; spdk_poller_get_state_str; spdk_poller_get_period_ticks; spdk_poller_get_stats; diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 17a760c710..53b3db1e6a 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -91,6 +91,7 @@ struct spdk_poller { uint64_t next_run_tick; uint64_t run_count; uint64_t busy_count; + uint64_t id; spdk_poller_fn fn; void *arg; struct spdk_thread *thread; @@ -142,6 +143,7 @@ struct spdk_thread { size_t msg_cache_count; spdk_msg_fn critical_msg; uint64_t id; + uint64_t next_poller_id; enum spdk_thread_state state; int pending_unregister_count; @@ -438,6 +440,11 @@ spdk_thread_create(const char *name, struct spdk_cpuset *cpumask) thread->tsc_last = spdk_get_ticks(); + /* Monotonic increasing ID is set to each created poller beginning at 1. Once the + * ID exceeds UINT64_MAX a warning message is logged + */ + thread->next_poller_id = 1; + thread->messages = spdk_ring_create(SPDK_RING_TYPE_MP_SC, 65536, SPDK_ENV_SOCKET_ID_ANY); if (!thread->messages) { SPDK_ERRLOG("Unable to allocate memory for message ring\n"); @@ -1518,6 +1525,11 @@ poller_register(spdk_poller_fn fn, poller->arg = arg; poller->thread = thread; poller->interruptfd = -1; + if (thread->next_poller_id == 0) { + SPDK_WARNLOG("Poller ID rolled over. Poller ID is duplicated.\n"); + thread->next_poller_id = 1; + } + poller->id = thread->next_poller_id++; poller->period_ticks = convert_us_to_ticks(period_microseconds); @@ -1712,6 +1724,12 @@ spdk_poller_get_name(struct spdk_poller *poller) return poller->name; } +uint64_t +spdk_poller_get_id(struct spdk_poller *poller) +{ + return poller->id; +} + const char * spdk_poller_get_state_str(struct spdk_poller *poller) {