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: John Levon <john.levon@nutanix.com> Change-Id: Idbdf1715ab30d08233b38aa7691f0212ae93a542 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11445 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
b16da6ca62
commit
58e75cf714
@ -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 */
|
/* TODO: wrapper to data structure */
|
||||||
static inline size_t
|
static inline size_t
|
||||||
vfio_user_migr_data_len(void)
|
vfio_user_migr_data_len(void)
|
||||||
@ -978,16 +995,6 @@ asq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
|
|||||||
return 0;
|
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
|
static int
|
||||||
acq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
|
acq_setup(struct nvmf_vfio_user_ctrlr *ctrlr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user