From fe5a044c937b875e769ef73f326c1e8d46a96bd5 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Tue, 10 Mar 2020 09:47:15 +0100 Subject: [PATCH] thread: Add poller run times counter This will be used by upcoming spdk_top application. Signed-off-by: Maciej Szwed Change-Id: I9ffcc3f2e36b8044bbc394938fc7a1dca1dc6892 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1211 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- doc/jsonrpc.md | 1 + include/spdk_internal/thread.h | 1 + lib/thread/thread.c | 4 ++++ module/event/rpc/app_rpc.c | 1 + 4 files changed, 7 insertions(+) diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 019497d8d..f21390a25 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -653,6 +653,7 @@ Example response: { "name": "spdk_rpc_subsystem_poll", "state": "waiting", + "run_count": 12345 "period_ticks": 10000000 } ], diff --git a/include/spdk_internal/thread.h b/include/spdk_internal/thread.h index 0f5da5444..15c445ae1 100644 --- a/include/spdk_internal/thread.h +++ b/include/spdk_internal/thread.h @@ -69,6 +69,7 @@ struct spdk_poller { uint64_t period_ticks; uint64_t next_run_tick; + uint64_t run_count; spdk_poller_fn fn; void *arg; struct spdk_thread *thread; diff --git a/lib/thread/thread.c b/lib/thread/thread.c index b3bc111c1..54bb97b7f 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -564,6 +564,8 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) poller->state = SPDK_POLLER_STATE_RUNNING; poller_rc = poller->fn(poller->arg); + poller->run_count++; + #ifdef DEBUG if (poller_rc == -1) { SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Poller %s returned -1\n", poller->name); @@ -603,6 +605,8 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) poller->state = SPDK_POLLER_STATE_RUNNING; timer_rc = poller->fn(poller->arg); + poller->run_count++; + #ifdef DEBUG if (timer_rc == -1) { SPDK_DEBUGLOG(SPDK_LOG_THREAD, "Timed poller %s returned -1\n", poller->name); diff --git a/module/event/rpc/app_rpc.c b/module/event/rpc/app_rpc.c index 9e225f982..aeb953385 100644 --- a/module/event/rpc/app_rpc.c +++ b/module/event/rpc/app_rpc.c @@ -232,6 +232,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", poller->name); spdk_json_write_named_string(w, "state", spdk_poller_state_str(poller->state)); + spdk_json_write_named_uint64(w, "run_count", poller->run_count); if (poller->period_ticks) { spdk_json_write_named_uint64(w, "period_ticks", poller->period_ticks); }