From cf6ee25359c9b5e67fd3e34b6370440795ee75b9 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 31 May 2018 06:46:07 -0700 Subject: [PATCH] nvme/overhead: remove extra spdk_get_ticks() The check_io function always calls spdk_get_ticks() - so return that value to the work_fn for checking when the test is complete, rather than have work_fn call spdk_get_ticks() again. This eliminates an extra rdtsc call that counts against the completion path. Signed-off-by: Jim Harris Change-Id: I5a4f52eb2bec70a119c9ea7368bc7f2e8f17155c Reviewed-on: https://review.gerrithub.io/413152 Tested-by: SPDK Automated Test System Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- test/nvme/overhead/overhead.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/nvme/overhead/overhead.c b/test/nvme/overhead/overhead.c index e25c7bada..053c99d65 100644 --- a/test/nvme/overhead/overhead.c +++ b/test/nvme/overhead/overhead.c @@ -334,7 +334,7 @@ io_complete(void *ctx, const struct spdk_nvme_cpl *completion) uint64_t g_complete_tsc_start; -static void +static uint64_t check_io(void) { uint64_t end, tsc_complete; @@ -378,8 +378,10 @@ check_io(void) if (!g_ns->is_draining) { submit_single_io(); } - g_complete_tsc_start = spdk_get_ticks(); + end = g_complete_tsc_start = spdk_get_ticks(); } + + return end; } static void @@ -438,7 +440,7 @@ cleanup_ns_worker_ctx(void) static int work_fn(void) { - uint64_t tsc_end; + uint64_t tsc_end, current; /* Allocate a queue pair for each namespace. */ if (init_ns_worker_ctx() != 0) { @@ -458,9 +460,9 @@ work_fn(void) * I/O will be submitted in the io_complete callback * to replace each I/O that is completed. */ - check_io(); + current = check_io(); - if (spdk_get_ticks() > tsc_end) { + if (current > tsc_end) { break; } }