Commit af8b5732 authored by Ben Walker's avatar Ben Walker
Browse files

nvmf: Optimize nvmf_ibv_send_wr_init



This function always shows up as one of the hottest functions when
profiling. I believe it is the memset that is expensive, so instead
use default initialization when the wr is declared on the stack
and just set the members that need to be updated in the function.
Also make the function inline for good measure.

Change-Id: I29e24cdd375311fa033b5a6df772ff4f73e35302
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 77e4ebe8
Loading
Loading
Loading
Loading
+23 −22
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ spdk_nvmf_rdma_conn_create(struct rdma_cm_id *id, uint16_t max_queue_depth, uint
	return rdma_conn;
}

static void
static inline void
nvmf_trace_ibv_sge(struct ibv_sge *sg_list)
{
	if (sg_list) {
@@ -320,7 +320,7 @@ nvmf_trace_ibv_sge(struct ibv_sge *sg_list)
	}
}

static void
static inline void
nvmf_ibv_send_wr_init(struct ibv_send_wr *wr,
		      struct spdk_nvmf_request *req,
		      struct ibv_sge *sg_list,
@@ -331,16 +331,14 @@ nvmf_ibv_send_wr_init(struct ibv_send_wr *wr,
	RTE_VERIFY(wr != NULL);
	RTE_VERIFY(sg_list != NULL);

	memset(wr, 0, sizeof(*wr));
	wr->wr_id = (uint64_t)rdma_req;
	wr->next = NULL;
	wr->opcode = opcode;
	wr->send_flags = send_flags;
	wr->sg_list = sg_list;
	wr->num_sge = 1;
}

static void
static inline void
nvmf_ibv_send_wr_set_rkey(struct ibv_send_wr *wr, struct spdk_nvmf_request *req)
{
	struct spdk_nvme_sgl_descriptor *sgl = &req->cmd->nvme_cmd.dptr.sgl1;
@@ -357,7 +355,8 @@ nvmf_ibv_send_wr_set_rkey(struct ibv_send_wr *wr, struct spdk_nvmf_request *req)
static int
nvmf_post_rdma_read(struct spdk_nvmf_request *req)
{
	struct ibv_send_wr wr, *bad_wr = NULL;
	struct ibv_send_wr	wr = {};
	struct ibv_send_wr	*bad_wr = NULL;
	struct spdk_nvmf_conn 	*conn = req->conn;
	struct spdk_nvmf_rdma_conn 	*rdma_conn = get_rdma_conn(conn);
	struct spdk_nvmf_rdma_session 	*rdma_sess;
@@ -391,7 +390,8 @@ nvmf_post_rdma_read(struct spdk_nvmf_request *req)
static int
nvmf_post_rdma_write(struct spdk_nvmf_request *req)
{
	struct ibv_send_wr wr, *bad_wr = NULL;
	struct ibv_send_wr	wr = {};
	struct ibv_send_wr	*bad_wr = NULL;
	struct spdk_nvmf_conn 	*conn = req->conn;
	struct spdk_nvmf_rdma_conn 	*rdma_conn = get_rdma_conn(conn);
	struct spdk_nvmf_rdma_session 	*rdma_sess;
@@ -461,7 +461,8 @@ nvmf_post_rdma_recv(struct spdk_nvmf_request *req)
static int
nvmf_post_rdma_send(struct spdk_nvmf_request *req)
{
	struct ibv_send_wr wr, *bad_wr = NULL;
	struct ibv_send_wr	wr = {};
	struct ibv_send_wr	*bad_wr = NULL;
	struct spdk_nvmf_conn 	*conn = req->conn;
	struct spdk_nvmf_rdma_conn 	*rdma_conn = get_rdma_conn(conn);
	struct ibv_sge 		sge;