thread: Factor out removing timed poller from list into a helper function

The following patches will update the cache to the closest timed
poller when removing it from the list. To do it easier, factor out
the operation to remove a timed poller from timed_pollers list into
a helper function.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I25016d86117b240a2651d1f06e23bea0342211f1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7719
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 10:12:58 +09:00 committed by Tomasz Zawadzki
parent c204c3d786
commit f5313b5501

View File

@ -578,6 +578,12 @@ poller_insert_timer(struct spdk_thread *thread, struct spdk_poller *poller, uint
TAILQ_INSERT_HEAD(&thread->timed_pollers, poller, tailq);
}
static inline void
poller_remove_timer(struct spdk_thread *thread, struct spdk_poller *poller)
{
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
}
static void
thread_insert_poller(struct spdk_thread *thread, struct spdk_poller *poller)
{
@ -665,11 +671,11 @@ thread_execute_timed_poller(struct spdk_thread *thread, struct spdk_poller *poll
switch (poller->state) {
case SPDK_POLLER_STATE_UNREGISTERED:
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
poller_remove_timer(thread, poller);
free(poller);
return 0;
case SPDK_POLLER_STATE_PAUSING:
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
poller_remove_timer(thread, poller);
TAILQ_INSERT_TAIL(&thread->paused_pollers, poller, tailq);
poller->state = SPDK_POLLER_STATE_PAUSED;
return 0;
@ -696,14 +702,14 @@ thread_execute_timed_poller(struct spdk_thread *thread, struct spdk_poller *poll
switch (poller->state) {
case SPDK_POLLER_STATE_UNREGISTERED:
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
poller_remove_timer(thread, poller);
free(poller);
break;
case SPDK_POLLER_STATE_PAUSED:
break;
case SPDK_POLLER_STATE_RUNNING:
poller->state = SPDK_POLLER_STATE_WAITING;
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
poller_remove_timer(thread, poller);
poller_insert_timer(thread, poller, now);
break;
default:
@ -1128,7 +1134,7 @@ period_poller_set_interrupt_mode(struct spdk_poller *poller, void *cb_arg, bool
*/
now_tick = now_tick - poller->period_ticks + ticks * old_tv.it_value.tv_sec + \
(ticks * old_tv.it_value.tv_nsec) / SPDK_SEC_TO_NSEC;
TAILQ_REMOVE(&poller->thread->timed_pollers, poller, tailq);
poller_remove_timer(poller->thread, poller);
poller_insert_timer(poller->thread, poller, now_tick);
}
}
@ -1427,7 +1433,7 @@ spdk_poller_pause(struct spdk_poller *poller)
break;
case SPDK_POLLER_STATE_RUNNING:
if (poller->period_ticks > 0) {
TAILQ_REMOVE(&thread->timed_pollers, poller, tailq);
poller_remove_timer(thread, poller);
} else {
TAILQ_REMOVE(&thread->active_pollers, poller, tailq);
}