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

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

Suggested-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
Change-Id: Id1e9d63a08e470344fdeb549d78ea505088b1a62
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11436
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
John Levon 2022-02-07 20:02:27 +00:00 committed by Jim Harris
parent 8fd0e680f2
commit b16da6ca62

View File

@ -446,7 +446,13 @@ static inline void
sq_head_advance(struct nvmf_vfio_user_sq *sq)
{
assert(sq != NULL);
*sq_headp(sq) = (*sq_headp(sq) + 1) % sq->size;
assert(*sq_headp(sq) < sq->size);
(*sq_headp(sq))++;
if (spdk_unlikely(*sq_headp(sq) == sq->size)) {
*sq_headp(sq) = 0;
}
}
static inline void