nvmf/vfio-user: don't read from completion entry

We were accidentally reading the spdk_nvme_status from the CPL; on one
test, this was contributing to 2% of cache misses.

Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: I7c967690458a183799f8d835360800d3094c3131
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11849
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: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
John Levon 2022-03-08 22:06:42 +00:00 committed by Jim Harris
parent 7a9d089b68
commit 586d1d6571

View File

@ -1086,8 +1086,9 @@ static int
post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq,
uint32_t cdw0, uint16_t sqid, uint16_t cid, uint16_t sc, uint16_t sct)
{
struct spdk_nvme_cpl *cpl;
struct spdk_nvme_status cpl_status = { 0 };
const struct spdk_nvmf_registers *regs;
struct spdk_nvme_cpl *cpl;
int err;
assert(ctrlr != NULL);
@ -1123,11 +1124,17 @@ post_completion(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq
cpl->sqid = sqid;
cpl->cid = cid;
cpl->cdw0 = cdw0;
cpl->status.dnr = 0x0;
cpl->status.m = 0x0;
cpl->status.sct = sct;
cpl->status.sc = sc;
cpl->status.p = cq->phase;
/*
* This is a bitfield: instead of setting the individual bits we need
* directly in cpl->status, which would cause a read-modify-write cycle,
* we'll avoid reading from the CPL altogether by filling in a local
* cpl_status variable, then writing the whole thing.
*/
cpl_status.sct = sct;
cpl_status.sc = sc;
cpl_status.p = cq->phase;
cpl->status = cpl_status;
/* Ensure the Completion Queue Entry is visible. */
spdk_wmb();