From acba80827aa14f1e8b58e0bc83e967ffafe08e34 Mon Sep 17 00:00:00 2001 From: John Levon Date: Tue, 26 Apr 2022 01:28:12 +0100 Subject: [PATCH] nvmf/vfio-user: reduce read barrier costs There's no need to spdk_rmb() in nvmf_vfio_user_sq_poll() unless we actually found the tail has advanced. Signed-off-by: John Levon Change-Id: I778835c527409764c3db78459b2aa76420cc0105 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12378 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu Reviewed-by: Thanos Makatos --- lib/nvmf/vfio_user.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index 03f68e89c..7fee75d6d 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -5112,13 +5112,6 @@ nvmf_vfio_user_sq_poll(struct nvmf_vfio_user_sq *sq) /* Load-Acquire. */ new_tail = *sq_dbl_tailp(sq); - /* - * Ensure that changes to the queue are visible to us. - * The host driver should write the queue first, do a wmb(), and then - * update the SQ tail doorbell (their Store-Release). - */ - spdk_rmb(); - new_tail = new_tail & 0xffffu; if (spdk_unlikely(new_tail >= sq->size)) { union spdk_nvme_async_event_completion event = {}; @@ -5147,6 +5140,13 @@ nvmf_vfio_user_sq_poll(struct nvmf_vfio_user_sq *sq) ctrlr->sdbl->eventidxs[queue_index(sq->qid, false)]); } + /* + * Ensure that changes to the queue are visible to us. + * The host driver should write the queue first, do a wmb(), and then + * update the SQ tail doorbell (their Store-Release). + */ + spdk_rmb(); + count = handle_sq_tdbl_write(ctrlr, new_tail, sq); if (count < 0) { fail_ctrlr(ctrlr);