Commit 012a1583 authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

nvme/perf: make the drain io in round robin.



This patch is used to make the io completion
of different ns_ctx owned by each worker in
a round robin way.

Purpose: To avoid the timeout if there are many
ns_ctxes. For example, if each ns_ctxt connects
to remote NVMe-oF target with qpair. If there are
many qpairs, we may face the time out of some qpairs.

Change-Id: I477cb7436dc46ea498a26f990ed79001fa1bf2d6
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/c/438150


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent ea002f50
Loading
Loading
Loading
Loading
+22 −15
Original line number Diff line number Diff line
@@ -787,15 +787,6 @@ submit_io(struct ns_worker_ctx *ns_ctx, int queue_depth)
	}
}

static void
drain_io(struct ns_worker_ctx *ns_ctx)
{
	ns_ctx->is_draining = true;
	while (ns_ctx->current_queue_depth > 0) {
		check_io(ns_ctx);
	}
}

static int
init_ns_worker_ctx(struct ns_worker_ctx *ns_ctx)
{
@@ -854,6 +845,7 @@ work_fn(void *arg)
	uint64_t tsc_end;
	struct worker_thread *worker = (struct worker_thread *)arg;
	struct ns_worker_ctx *ns_ctx = NULL;
	uint32_t unfinished_ns_ctx;

	printf("Starting thread on core %u\n", worker->lcore);

@@ -893,12 +885,27 @@ work_fn(void *arg)
		}
	}

	/* drain the io of each ns_ctx in round robin to make the fairness */
	do {
		unfinished_ns_ctx = 0;
		ns_ctx = worker->ns_ctx;
		while (ns_ctx != NULL) {
		drain_io(ns_ctx);
			/* first time will enter into this if case */
			if (!ns_ctx->is_draining) {
				ns_ctx->is_draining = true;
			}

			if (ns_ctx->current_queue_depth > 0) {
				check_io(ns_ctx);
				if (ns_ctx->current_queue_depth == 0) {
					cleanup_ns_worker_ctx(ns_ctx);
				} else {
					unfinished_ns_ctx++;
				}
			}
			ns_ctx = ns_ctx->next;
		}
	} while (unfinished_ns_ctx > 0);

	return 0;
}