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

lib/thread: Factor out main loops of spdk_thread_poll() into a helper function



This is another preparation to extende spdk_thread_poll() to update
thread stats correctly on multiple SPDK threads per CPU core
configuration as an new function spdk_thread_poll_ext().

As another preparation, factor out main loops of spdk_thread_poll()
to _spdk_thread_poll(). _spdk_thread_poll() will be called in
spdk_thread_poll_ext() in the next patch.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie006359c00afc2e9b90e15f918f76cf1af0b7ce1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1255


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 avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 82ef7574
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -532,22 +532,14 @@ _spdk_thread_update_stats(struct spdk_thread *thread, uint64_t now, int rc)
	thread->tsc_last = now;
}

int
spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
static int
_spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
{
	uint32_t msg_count;
	struct spdk_thread *orig_thread;
	struct spdk_poller *poller, *tmp;
	spdk_msg_fn critical_msg;
	int rc = 0;

	orig_thread = _get_thread();
	tls_thread = thread;

	if (now == 0) {
		now = spdk_get_ticks();
	}

	critical_msg = thread->critical_msg;
	if (spdk_unlikely(critical_msg != NULL)) {
		critical_msg(NULL);
@@ -640,6 +632,24 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
		}
	}

	return rc;
}

int
spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
{
	struct spdk_thread *orig_thread;
	int rc;

	orig_thread = _get_thread();
	tls_thread = thread;

	if (now == 0) {
		now = spdk_get_ticks();
	}

	rc = _spdk_thread_poll(thread, max_msgs, now);

	_spdk_thread_update_stats(thread, now, rc);

	tls_thread = orig_thread;