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

lib/thread: Rename timer_poller by timed_poller



Rename all variables and comments related with timed poller from
timer_poller to timed_poller.

This patch was originally to count poller and add the current
value to thread_get_stats RPC. This will be realized to add
thread_get_pollers RPC instead but renaming will be valuable itself.
So keep only renaming in this patch.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@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>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 242a8995
Loading
Loading
Loading
Loading
+16 −19
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ struct spdk_thread {
	/**
	 * Contains pollers running on this thread with a periodic timer.
	 */
	TAILQ_HEAD(timer_pollers_head, spdk_poller)	timer_pollers;
	TAILQ_HEAD(timed_pollers_head, spdk_poller)	timed_pollers;

	/*
	 * Contains paused pollers.  Pollers on this queue are waiting until
@@ -227,19 +227,16 @@ _free_thread(struct spdk_thread *thread)
			SPDK_WARNLOG("poller %p still registered at thread exit\n",
				     poller);
		}

		TAILQ_REMOVE(&thread->active_pollers, poller, tailq);
		free(poller);
	}


	TAILQ_FOREACH_SAFE(poller, &thread->timer_pollers, tailq, ptmp) {
	TAILQ_FOREACH_SAFE(poller, &thread->timed_pollers, tailq, ptmp) {
		if (poller->state != SPDK_POLLER_STATE_UNREGISTERED) {
			SPDK_WARNLOG("poller %p still registered at thread exit\n",
				     poller);
		}

		TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
		TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
		free(poller);
	}

@@ -293,7 +290,7 @@ spdk_thread_create(const char *name, struct spdk_cpuset *cpumask)

	TAILQ_INIT(&thread->io_channels);
	TAILQ_INIT(&thread->active_pollers);
	TAILQ_INIT(&thread->timer_pollers);
	TAILQ_INIT(&thread->timed_pollers);
	TAILQ_INIT(&thread->paused_pollers);
	SLIST_INIT(&thread->msg_cache);
	thread->msg_cache_count = 0;
@@ -458,18 +455,18 @@ _spdk_poller_insert_timer(struct spdk_thread *thread, struct spdk_poller *poller
	poller->next_run_tick = now + poller->period_ticks;

	/*
	 * Insert poller in the thread's timer_pollers list in sorted order by next scheduled
	 * Insert poller in the thread's timed_pollers list in sorted order by next scheduled
	 * run time.
	 */
	TAILQ_FOREACH_REVERSE(iter, &thread->timer_pollers, timer_pollers_head, tailq) {
	TAILQ_FOREACH_REVERSE(iter, &thread->timed_pollers, timed_pollers_head, tailq) {
		if (iter->next_run_tick <= poller->next_run_tick) {
			TAILQ_INSERT_AFTER(&thread->timer_pollers, iter, poller, tailq);
			TAILQ_INSERT_AFTER(&thread->timed_pollers, iter, poller, tailq);
			return;
		}
	}

	/* No earlier pollers were found, so this poller must be the new head */
	TAILQ_INSERT_HEAD(&thread->timer_pollers, poller, tailq);
	TAILQ_INSERT_HEAD(&thread->timed_pollers, poller, tailq);
}

static void
@@ -549,7 +546,7 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
		}
	}

	TAILQ_FOREACH_SAFE(poller, &thread->timer_pollers, tailq, tmp) {
	TAILQ_FOREACH_SAFE(poller, &thread->timed_pollers, tailq, tmp) {
		int timer_rc = 0;

		if (thread->exit) {
@@ -557,11 +554,11 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
		}

		if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
			free(poller);
			continue;
		} else if (poller->state == SPDK_POLLER_STATE_PAUSING) {
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
			TAILQ_INSERT_TAIL(&thread->paused_pollers, poller, tailq);
			poller->state = SPDK_POLLER_STATE_PAUSED;
			continue;
@@ -581,11 +578,11 @@ spdk_thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
#endif

		if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) {
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
			free(poller);
		} else if (poller->state != SPDK_POLLER_STATE_PAUSED) {
			poller->state = SPDK_POLLER_STATE_WAITING;
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
			_spdk_poller_insert_timer(thread, poller, now);
		}

@@ -613,7 +610,7 @@ spdk_thread_next_poller_expiration(struct spdk_thread *thread)
{
	struct spdk_poller *poller;

	poller = TAILQ_FIRST(&thread->timer_pollers);
	poller = TAILQ_FIRST(&thread->timed_pollers);
	if (poller) {
		return poller->next_run_tick;
	}
@@ -631,7 +628,7 @@ static bool
_spdk_thread_has_unpaused_pollers(struct spdk_thread *thread)
{
	if (TAILQ_EMPTY(&thread->active_pollers) &&
	    TAILQ_EMPTY(&thread->timer_pollers)) {
	    TAILQ_EMPTY(&thread->timed_pollers)) {
		return false;
	}

@@ -866,7 +863,7 @@ spdk_poller_pause(struct spdk_poller *poller)
		poller->state = SPDK_POLLER_STATE_PAUSING;
	} else {
		if (poller->period_ticks > 0) {
			TAILQ_REMOVE(&thread->timer_pollers, poller, tailq);
			TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
		} else {
			TAILQ_REMOVE(&thread->active_pollers, poller, tailq);
		}