thread: add spdk_poller_get_id
Issue: spdk_top tracked pollers by the poller name string and the thread_id they are running on. This shows incorrect stats when multiple pollers exist on the same thread with the same name. Solution: Added a unique poller id for each poller on a thread and to allow spdk_top to track pollers by thread_id and poller_id. Signed-off-by: Michael Piszczek <mpiszczek@ddn.com> Change-Id: I1879e2afc9a929d1df9e8e35510f0092c5443bdc Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5868 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
c0babf5347
commit
29c0e0dc3e
@ -1310,6 +1310,7 @@ Example response:
|
||||
"timed_pollers": [
|
||||
{
|
||||
"name": "spdk_rpc_subsystem_poll",
|
||||
"id": 1,
|
||||
"state": "waiting",
|
||||
"run_count": 12345,
|
||||
"busy_count": 10000,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user