From 48738e383dce250e8a580e524640510cea47a124 Mon Sep 17 00:00:00 2001 From: Vishal Verma Date: Mon, 28 May 2018 16:18:04 -0700 Subject: [PATCH] event: Remove timer poll count checks This removes checks for timer poll iterations within a reactor. Change-Id: Id8eea26dab201064123575998b3b24e1f609ac5a Signed-off-by: Vishal Verma Reviewed-on: https://review.gerrithub.io/412694 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- lib/event/reactor.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 28c8f4764..7bd694292 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -45,7 +45,6 @@ #define SPDK_MAX_SOCKET 64 #define SPDK_REACTOR_SPIN_TIME_USEC 1000 -#define SPDK_TIMER_POLL_ITERATIONS 5 #define SPDK_EVENT_BATCH_SIZE 8 #define SPDK_SEC_TO_USEC 1000000ULL @@ -439,7 +438,6 @@ _spdk_reactor_run(void *arg) uint64_t idle_started, now; uint64_t spin_cycles, sleep_cycles; uint32_t sleep_us; - uint32_t timer_poll_count; char thread_name[32]; snprintf(thread_name, sizeof(thread_name), "reactor_%u", reactor->lcore); @@ -455,7 +453,6 @@ _spdk_reactor_run(void *arg) spin_cycles = SPDK_REACTOR_SPIN_TIME_USEC * spdk_get_ticks_hz() / SPDK_SEC_TO_USEC; sleep_cycles = reactor->max_delay_us * spdk_get_ticks_hz() / SPDK_SEC_TO_USEC; idle_started = 0; - timer_poll_count = 0; if (g_context_switch_monitor_enabled) { _spdk_reactor_context_switch_monitor_start(reactor, NULL); } @@ -481,27 +478,22 @@ _spdk_reactor_run(void *arg) took_action = true; } - if (timer_poll_count >= SPDK_TIMER_POLL_ITERATIONS) { - poller = TAILQ_FIRST(&reactor->timer_pollers); - if (poller) { - now = spdk_get_ticks(); + poller = TAILQ_FIRST(&reactor->timer_pollers); + if (poller) { + now = spdk_get_ticks(); - if (now >= poller->next_run_tick) { - TAILQ_REMOVE(&reactor->timer_pollers, poller, tailq); - poller->state = SPDK_POLLER_STATE_RUNNING; - poller->fn(poller->arg); - if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) { - free(poller); - } else { - poller->state = SPDK_POLLER_STATE_WAITING; - _spdk_poller_insert_timer(reactor, poller, now); - } - took_action = true; + if (now >= poller->next_run_tick) { + TAILQ_REMOVE(&reactor->timer_pollers, poller, tailq); + poller->state = SPDK_POLLER_STATE_RUNNING; + poller->fn(poller->arg); + if (poller->state == SPDK_POLLER_STATE_UNREGISTERED) { + free(poller); + } else { + poller->state = SPDK_POLLER_STATE_WAITING; + _spdk_poller_insert_timer(reactor, poller, now); } + took_action = true; } - timer_poll_count = 0; - } else { - timer_poll_count++; } if (took_action) { @@ -536,8 +528,6 @@ _spdk_reactor_run(void *arg) usleep(sleep_us); } - /* After sleeping, always poll for timers */ - timer_poll_count = SPDK_TIMER_POLL_ITERATIONS; } }