Commit 58e75cf7 authored by John Levon's avatar John Levon Committed by Jim Harris
Browse files

nvmf/vfio-user: avoid division in cq_is_full()



Avoid using the modulus operator in the hot-path cq_is_full(),
by aping how cq_tail_advance() is written.

Signed-off-by: default avatarJohn Levon <john.levon@nutanix.com>
Change-Id: Idbdf1715ab30d08233b38aa7691f0212ae93a542
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11445


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
parent b16da6ca
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -469,6 +469,23 @@ cq_tail_advance(struct nvmf_vfio_user_cq *cq)
	}
}

static inline bool
cq_is_full(struct nvmf_vfio_user_ctrlr *ctrlr, struct nvmf_vfio_user_cq *cq)
{
	uint32_t qindex;

	assert(ctrlr != NULL);
	assert(cq != NULL);

	qindex = *cq_tailp(cq) + 1;
	if (spdk_unlikely(qindex == cq->size)) {
		qindex = 0;
	}

	return qindex == *cq_dbl_headp(ctrlr, cq);
}


/* TODO: wrapper to data structure */
static inline size_t
vfio_user_migr_data_len(void)
@@ -978,16 +995,6 @@ asq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
	return 0;
}

static inline bool
cq_is_full(struct nvmf_vfio_user_ctrlr *ctrlr,
	   struct nvmf_vfio_user_cq *cq)
{
	assert(ctrlr != NULL);
	assert(cq != NULL);

	return ((*cq_tailp(cq) + 1) % cq->size) == *cq_dbl_headp(ctrlr, cq);
}

static int
acq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
{