Commit 82ef7574 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I93c40eb0363ca34f2150299b09c49f1401583832
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1242


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 347e1d39
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -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;