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

thread: Consolidate poller_remove_timer() calls into a single place



This enable us to optimize the cache update when RB tree is supported.

Call poller_remove_timer() after getting the next element because
as TAILQ_FOREACH_SAFE() and RB_FOREACH_SAFE() do, TAILQ_NEXT() may
not be valid after the current element is removed.

Previously, the patch had called poller_remove_timer() before getting
the next element. However, thanks to the nice testing, this bug was
found.

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


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 3ca15e33
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -784,11 +784,9 @@ thread_execute_timed_poller(struct spdk_thread *thread, struct spdk_poller *poll

	switch (poller->state) {
	case SPDK_POLLER_STATE_UNREGISTERED:
		poller_remove_timer(thread, poller);
		free(poller);
		return 0;
	case SPDK_POLLER_STATE_PAUSING:
		poller_remove_timer(thread, poller);
		TAILQ_INSERT_TAIL(&thread->paused_pollers, poller, tailq);
		poller->state = SPDK_POLLER_STATE_PAUSED;
		return 0;
@@ -815,11 +813,9 @@ thread_execute_timed_poller(struct spdk_thread *thread, struct spdk_poller *poll

	switch (poller->state) {
	case SPDK_POLLER_STATE_UNREGISTERED:
		poller_remove_timer(thread, poller);
		free(poller);
		break;
	case SPDK_POLLER_STATE_PAUSING:
		poller_remove_timer(thread, poller);
		TAILQ_INSERT_TAIL(&thread->paused_pollers, poller, tailq);
		poller->state = SPDK_POLLER_STATE_PAUSED;
		break;
@@ -829,7 +825,6 @@ thread_execute_timed_poller(struct spdk_thread *thread, struct spdk_poller *poll
		poller->state = SPDK_POLLER_STATE_WAITING;
	/* fallthrough */
	case SPDK_POLLER_STATE_WAITING:
		poller_remove_timer(thread, poller);
		poller_insert_timer(thread, poller, now);
		break;
	default:
@@ -881,6 +876,7 @@ thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
		}

		tmp = TAILQ_NEXT(poller, tailq);
		poller_remove_timer(thread, poller);

		timer_rc = thread_execute_timed_poller(thread, poller, now);
		if (timer_rc > rc) {