From 9e8853953a448cd09d2f8cf4867c7b0d4779373c Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 25 Aug 2017 16:25:57 +0800 Subject: [PATCH] fio_plugin: Poll qpairs on the same thread in round-robin manner With this change, the polling qpairs can be in round-robin manner. Change-Id: I1926468dc596de2a43f42451525650356f44fbbd Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/375707 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris --- examples/nvme/fio_plugin/fio_plugin.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/nvme/fio_plugin/fio_plugin.c b/examples/nvme/fio_plugin/fio_plugin.c index bd302fe58b..418cf94d54 100644 --- a/examples/nvme/fio_plugin/fio_plugin.c +++ b/examples/nvme/fio_plugin/fio_plugin.c @@ -80,6 +80,7 @@ struct spdk_fio_thread { struct thread_data *td; struct spdk_fio_qpair *fio_qpair; + struct spdk_fio_qpair *fio_qpair_current; // the current fio_qpair to be handled. struct io_u **iocq; // io completion queue unsigned int iocq_count; // number of iocq entries filled by last getevents @@ -413,7 +414,7 @@ static int spdk_fio_getevents(struct thread_data *td, unsigned int min, unsigned int max, const struct timespec *t) { struct spdk_fio_thread *fio_thread = td->io_ops_data; - struct spdk_fio_qpair *fio_qpair; + struct spdk_fio_qpair *fio_qpair = NULL; struct timespec t0, t1; uint64_t timeout = 0; @@ -424,12 +425,22 @@ static int spdk_fio_getevents(struct thread_data *td, unsigned int min, fio_thread->iocq_count = 0; + /* fetch the next qpair */ + if (fio_thread->fio_qpair_current) { + fio_qpair = fio_thread->fio_qpair_current->next; + } + for (;;) { - fio_qpair = fio_thread->fio_qpair; + if (fio_qpair == NULL) { + fio_qpair = fio_thread->fio_qpair; + } + while (fio_qpair != NULL) { spdk_nvme_qpair_process_completions(fio_qpair->qpair, max - fio_thread->iocq_count); if (fio_thread->iocq_count >= min) { + /* reset the currrent handling qpair */ + fio_thread->fio_qpair_current = fio_qpair; return fio_thread->iocq_count; } @@ -448,6 +459,8 @@ static int spdk_fio_getevents(struct thread_data *td, unsigned int min, } } + /* reset the currrent handling qpair */ + fio_thread->fio_qpair_current = fio_qpair; return fio_thread->iocq_count; }