From 82ef75748ae32d4c6cb653c5dcebc626e5cfceb4 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Fri, 13 Mar 2020 10:25:01 +0900 Subject: [PATCH] lib/thread: Factor out updating thread stats from spdk_thread_poll() Subsequent patches will extend spdk_thread_poll() to update thread stats correctly on multiple SPDK threads per CPU core configuration as an new function spdk_thread_poll_ext(). Thread stats will be updated separately by spdk_thread_poll() and spdk_thread_poll_ext(), but updating thread stats itself is the common operation. Hence as a preparation, factor out updating thread stats operation from spdk_thread_poll() to _spdk_thread_update_stats(). Signed-off-by: Shuhei Matsumoto Change-Id: I93c40eb0363ca34f2150299b09c49f1401583832 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1242 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- lib/thread/thread.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 54bb97b7f..3ee25d9f2 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -519,6 +519,19 @@ _spdk_thread_insert_poller(struct spdk_thread *thread, struct spdk_poller *polle } } +static inline void +_spdk_thread_update_stats(struct spdk_thread *thread, uint64_t now, int rc) +{ + if (rc == 0) { + /* Poller status idle */ + thread->stats.idle_tsc += now - thread->tsc_last; + } else if (rc > 0) { + /* Poller status busy */ + thread->stats.busy_tsc += now - thread->tsc_last; + } + thread->tsc_last = now; +} + int spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) { @@ -627,14 +640,7 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now) } } - if (rc == 0) { - /* Poller status idle */ - thread->stats.idle_tsc += now - thread->tsc_last; - } else if (rc > 0) { - /* Poller status busy */ - thread->stats.busy_tsc += now - thread->tsc_last; - } - thread->tsc_last = now; + _spdk_thread_update_stats(thread, now, rc); tls_thread = orig_thread;