event: Always process events on each reactor loop

Events are the mechanism by which threads are scheduled,
so events need to be processed even if there are no
threads.

Change-Id: I2e908e6a948709f2122b1c7385b6fd771827b9aa
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447111
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2019-03-05 13:57:51 -07:00
parent deb8ee5c33
commit 2d0aa1ad8f

View File

@ -134,10 +134,12 @@ spdk_event_call(struct spdk_event *event)
}
static inline uint32_t
_spdk_event_queue_run_batch(struct spdk_reactor *reactor, struct spdk_thread *thread)
_spdk_event_queue_run_batch(struct spdk_reactor *reactor)
{
unsigned count, i;
void *events[SPDK_EVENT_BATCH_SIZE];
struct spdk_thread *thread;
struct spdk_lw_thread *lw_thread;
#ifdef DEBUG
/*
@ -153,6 +155,16 @@ _spdk_event_queue_run_batch(struct spdk_reactor *reactor, struct spdk_thread *th
return 0;
}
/* Execute the events. There are still some remaining events
* that must occur on an SPDK thread. To accomodate those, try to
* run them on the first thread in the list, if it exists. */
lw_thread = TAILQ_FIRST(&reactor->threads);
if (lw_thread) {
thread = spdk_thread_get_from_ctx(lw_thread);
} else {
thread = NULL;
}
spdk_set_thread(thread);
for (i = 0; i < count; i++) {
@ -239,11 +251,11 @@ _spdk_reactor_run(void *arg)
* is used for all threads. */
now = spdk_get_ticks();
_spdk_event_queue_run_batch(reactor);
TAILQ_FOREACH_SAFE(lw_thread, &reactor->threads, link, tmp) {
thread = spdk_thread_get_from_ctx(lw_thread);
_spdk_event_queue_run_batch(reactor, thread);
spdk_thread_poll(thread, 0, now);
}