Commit 7bcdc559 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

crypto: Use bulk API to return mbufs and crypto ops in poller



Performance testing shows much better CPU scalling with FIO as
DPDK will no longer take multiple locks with each loop.  Instead,
just 2 at the end to perform the bulk returns.

Change-Id: Ie4d556264302f01c2a9498be83b7bccbaf16b287
Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/427158


Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent ad06d03a
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -443,6 +443,8 @@ crypto_dev_poller(void *args)
	struct spdk_bdev_io *bdev_io = NULL;
	struct crypto_bdev_io *io_ctx = NULL;
	struct rte_crypto_op *dequeued_ops[MAX_DEQUEUE_BURST_SIZE];
	struct rte_crypto_op *mbufs_to_free[2 * MAX_DEQUEUE_BURST_SIZE];
	int num_mbufs = 0;

	/* Each run of the poller will get just what the device has available
	 * at the moment we call it, we don't check again after draining the
@@ -474,15 +476,13 @@ crypto_dev_poller(void *args)
		io_ctx = (struct crypto_bdev_io *)bdev_io->driver_ctx;
		assert(io_ctx->cryop_cnt_remaining > 0);

		/* return the associated src_mbufs */
		dequeued_ops[i]->sym->m_src->userdata = NULL;
		spdk_mempool_put(g_mbuf_mp, dequeued_ops[i]->sym->m_src);

		/* For encryption, free the mbuf we used to encrypt, the data buffer
		 * will be freed on write completion.
		/* Return the associated src and dst mbufs by collecting them into
		 * an array that we can use the bulk API to free after the loop.
		 */
		dequeued_ops[i]->sym->m_src->userdata = NULL;
		mbufs_to_free[num_mbufs++] = (void *)dequeued_ops[i]->sym->m_src;
		if (dequeued_ops[i]->sym->m_dst) {
			spdk_mempool_put(g_mbuf_mp, dequeued_ops[i]->sym->m_dst);
			mbufs_to_free[num_mbufs++] = (void *)dequeued_ops[i]->sym->m_dst;
		}

		/* done encrypting, complete the bdev_io */
@@ -495,10 +495,19 @@ crypto_dev_poller(void *args)
			rte_cryptodev_sym_session_clear(cdev_id, dequeued_ops[i]->sym->session);
			rte_cryptodev_sym_session_free(dequeued_ops[i]->sym->session);
		}
	}

		/* Free the operation */
		rte_crypto_op_free(dequeued_ops[i]);
	/* Now bulk free both mbufs and crypto operations. */
	if (num_dequeued_ops > 0) {
		rte_mempool_put_bulk(g_crypto_op_mp,
				     (void **)dequeued_ops,
				     num_dequeued_ops);
		assert(num_mbufs > 0);
		spdk_mempool_put_bulk(g_mbuf_mp,
				      (void **)mbufs_to_free,
				      num_mbufs);
	}

	return num_dequeued_ops;
}