From 7d44b36e0d5563d411e70109fe1dc92810e400ca Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 30 Mar 2023 18:27:42 +0000 Subject: [PATCH] nvme: only prefetch req's stailq when req != NULL It is fine to prefetch an invalid address, but ASAN doesn't like it. So move the prefetch slightly to make ASAN happy. Signed-off-by: Jim Harris Change-Id: Ib51ab8890e5fe91d30057f65e1399cfc9dd1dd49 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17432 Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Aleksey Marchuk Tested-by: SPDK CI Jenkins --- lib/nvme/nvme_pcie_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nvme/nvme_pcie_common.c b/lib/nvme/nvme_pcie_common.c index 90330c208..a64a3a278 100644 --- a/lib/nvme/nvme_pcie_common.c +++ b/lib/nvme/nvme_pcie_common.c @@ -925,13 +925,13 @@ nvme_pcie_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_ } tr = &pqpair->tr[cpl->cid]; - /* Prefetch the req's STAILQ_ENTRY since we'll need to access it - * as part of putting the req back on the qpair's free list. - */ - __builtin_prefetch(&tr->req->stailq); pqpair->sq_head = cpl->sqhd; if (tr->req) { + /* Prefetch the req's STAILQ_ENTRY since we'll need to access it + * as part of putting the req back on the qpair's free list. + */ + __builtin_prefetch(&tr->req->stailq); nvme_pcie_qpair_complete_tracker(qpair, tr, cpl, true); } else { SPDK_ERRLOG("cpl does not map to outstanding cmd\n");