Commit 8abfb06e authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

thread: Optionally allow the current time to be passed to


spdk_thread_poll()

This is an optimization if the calling function already knows the
current time.

Change-Id: I1645e08e7475ba6345a44e0f9d4b297a79f6c3c2
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/443634


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 15d36310
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -649,7 +649,7 @@ spdk_fio_event(struct thread_data *td, int event)
static size_t
spdk_fio_poll_thread(struct spdk_fio_thread *fio_thread)
{
	return spdk_thread_poll(fio_thread->thread, 0);
	return spdk_thread_poll(fio_thread->thread, 0, 0);
}

static int
+3 −1
Original line number Diff line number Diff line
@@ -216,10 +216,12 @@ void spdk_thread_exit(struct spdk_thread *thread);
 * \param thread The thread to process
 * \param max_msgs The maximum number of messages that will be processed.
 *                 Use 0 to process the default number of messages (8).
 * \param now The current time, in ticks. Optional. If 0 is passed, this
 *            function may call spdk_get_ticks() to get the current time.
 *
 * \return 1 if work was done. 0 if no work was done. -1 if unknown.
 */
int spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs);
int spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now);

/**
 * Return the number of ticks until the next timed poller
+1 −1
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ _spdk_reactor_run(void *arg)
	while (1) {
		_spdk_event_queue_run_batch(reactor, thread);

		rc = spdk_thread_poll(thread, 0);
		rc = spdk_thread_poll(thread, 0, 0);

		/* Determine if the thread can sleep */
		if (sleep_cycles && rc == 0) {
+5 −5
Original line number Diff line number Diff line
@@ -372,17 +372,20 @@ _spdk_poller_insert_timer(struct spdk_thread *thread, struct spdk_poller *poller
}

int
spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs)
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;
	int rc = 0;
	uint64_t now;

	orig_thread = _get_thread();
	tls_thread = thread;

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

	msg_count = _spdk_msg_queue_run_batch(thread, max_msgs);
	if (msg_count) {
		rc = 1;
@@ -415,8 +418,6 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs)

	poller = TAILQ_FIRST(&thread->timer_pollers);
	if (poller) {
		uint64_t now = spdk_get_ticks();

		if (now >= poller->next_run_tick) {
			int timer_rc = 0;

@@ -443,7 +444,6 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs)
		}
	}

	now = spdk_get_ticks();
	if (rc == 0) {
		/* Poller status idle */
		thread->stats.idle_tsc += now - thread->tsc_last;
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ poll_thread(uintptr_t thread_id)
	original_thread_id = g_thread_id;
	set_thread(INVALID_THREAD);

	while (spdk_thread_poll(thread->thread, 0) > 0) {
	while (spdk_thread_poll(thread->thread, 0, 0) > 0) {
		busy = true;
	}

Loading