thread: Change TAILQ_FOREACH_SAFE to TAILQ_FIRST() and _NEXT() for timed poller

When we introduce red black tree for timed pollers, we will not use
RB_FOREACH_SAFE() but cache the leftmost (smallest) node and iterate
from it via RB_NEXT() instead.

As another preparation, separate TAILQ_FOREACH_SAFE() into TAILQ_FIRST()
and TAILQ_NEXT().

The next patch will cache the first element to thread and refer it
first.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Ie03c387b5b3a055c668e7b439a5eb05ed77eaa81
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7718
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-05-03 09:30:50 +09:00 committed by Tomasz Zawadzki
parent aca41b43a3
commit c204c3d786

View File

@ -746,17 +746,22 @@ thread_poll(struct spdk_thread *thread, uint32_t max_msgs, uint64_t now)
}
}
TAILQ_FOREACH_SAFE(poller, &thread->timed_pollers, tailq, tmp) {
poller = TAILQ_FIRST(&thread->timed_pollers);
while (poller != NULL) {
int timer_rc = 0;
if (now < poller->next_run_tick) {
break;
}
tmp = TAILQ_NEXT(poller, tailq);
timer_rc = thread_execute_timed_poller(thread, poller, now);
if (timer_rc > rc) {
rc = timer_rc;
}
poller = tmp;
}
return rc;