From 2632229b9d991e339a29ea67b92801ad3fc8d739 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 29 May 2019 02:38:50 -0700 Subject: [PATCH] nvme/perf: only call verify_io when md_size > 0 verify_io is a function pointer, so avoiding the call altogether is beneficial. We know that no verification is possible if md_size == 0, so use this to determine if the call should be made. Signed-off-by: Jim Harris Change-Id: I75f01e4f56aacb0f7babd2342efc6014f886667d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456249 Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Paul Luse Tested-by: SPDK CI Jenkins --- examples/nvme/perf/perf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 223e0d9a8..46973ee11 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -46,6 +46,7 @@ #include "spdk/dif.h" #include "spdk/util.h" #include "spdk/log.h" +#include "spdk/likely.h" #if HAVE_LIBAIO #include @@ -548,8 +549,7 @@ nvme_verify_io(struct perf_task *task, struct ns_entry *entry) struct spdk_dif_error err_blk = {}; int rc; - if (!task->is_read || entry->md_size == 0 || - (entry->io_flags & SPDK_NVME_IO_FLAGS_PRACT)) { + if (!task->is_read || (entry->io_flags & SPDK_NVME_IO_FLAGS_PRACT)) { return; } @@ -917,8 +917,10 @@ task_complete(struct perf_task *task) spdk_histogram_data_tally(ns_ctx->histogram, tsc_diff); } - /* add application level verification for end-to-end data protection */ - entry->fn_table->verify_io(task, entry); + if (spdk_unlikely(entry->md_size > 0)) { + /* add application level verification for end-to-end data protection */ + entry->fn_table->verify_io(task, entry); + } /* * is_draining indicates when time has expired for the test run