Commit 5a7b33ec authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

nvmf/tcp: In _pdu_write_done, free pdu before calling user callback



By releasing the just-completed PDU prior to calling the callback,
for flows that immediately submit another PDU inside the callback,
the just-released PDU can be immediately reused. This reduces the number
of PDUs required in the pool to continue forward progress to half of the
previous value, while also making it more CPU cache friendly.

Change-Id: I8031b8f9f57ac05f261d96433d9899fe5e31d318
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479904


Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-by: default avatarOr Gerlitz <gerlitz.or@gmail.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 931ac757
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -764,10 +764,12 @@ spdk_nvmf_tcp_qpair_disconnect(struct spdk_nvmf_tcp_qpair *tqpair)
}

static void
_pdu_write_done(void *cb_arg, int err)
_pdu_write_done(void *_pdu, int err)
{
	struct nvme_tcp_pdu *pdu = cb_arg;
	struct nvme_tcp_pdu			*pdu = _pdu;
	struct spdk_nvmf_tcp_qpair		*tqpair = pdu->qpair;
	nvme_tcp_qpair_xfer_complete_cb		cb_fn;
	void					*cb_arg;

	TAILQ_REMOVE(&tqpair->send_queue, pdu, tailq);

@@ -783,9 +785,15 @@ _pdu_write_done(void *cb_arg, int err)
	}

	assert(pdu->cb_fn != NULL);
	pdu->cb_fn(pdu->cb_arg);

	/* Capture the callback and argument so we can free the PDU
	 * prior to calling the callback. */
	cb_fn = pdu->cb_fn;
	cb_arg = pdu->cb_arg;

	spdk_nvmf_tcp_pdu_put(tqpair, pdu);

	cb_fn(cb_arg);
}

static void