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 <john.levon@nutanix.com>
Change-Id: I778835c527409764c3db78459b2aa76420cc0105
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12378
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
This commit is contained in:
John Levon 2022-04-26 01:28:12 +01:00 committed by Tomasz Zawadzki
parent f89cf818c0
commit acba80827a

View File

@ -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);