From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yongseok Koh Subject: [PATCH v2 2/5] net/mlx5: free buffers in bulk on Tx completion Date: Fri, 30 Jun 2017 12:23:30 -0700 Message-ID: References: <20170628230403.10142-1-yskoh@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org, adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com, Yongseok Koh To: ferruh.yigit@intel.com Return-path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50088.outbound.protection.outlook.com [40.107.5.88]) by dpdk.org (Postfix) with ESMTP id 095395587 for ; Fri, 30 Jun 2017 21:23:48 +0200 (CEST) In-Reply-To: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When processing Tx completion, it is more efficient to free buffers in bulk using rte_mempool_put_bulk() if buffers are from a same mempool. Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5_rxtx.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 43db06ad8..66593679f 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -264,6 +264,9 @@ txq_complete(struct txq *txq) uint16_t cq_ci = txq->cq_ci; volatile struct mlx5_cqe *cqe = NULL; volatile struct mlx5_wqe_ctrl *ctrl; + struct rte_mbuf *m, *free[elts_n]; + struct rte_mempool *pool = NULL; + unsigned int blk_n = 0; do { volatile struct mlx5_cqe *tmp; @@ -296,21 +299,33 @@ txq_complete(struct txq *txq) assert((elts_tail & elts_m) < (1 << txq->wqe_n)); /* Free buffers. */ while (elts_free != elts_tail) { - struct rte_mbuf *elt = (*txq->elts)[elts_free & elts_m]; - struct rte_mbuf *elt_next = - (*txq->elts)[(elts_free + 1) & elts_m]; - + m = rte_pktmbuf_prefree_seg((*txq->elts)[elts_free++ & elts_m]); + if (likely(m != NULL)) { + if (likely(m->pool == pool)) { + free[blk_n++] = m; + } else { + if (likely(pool != NULL)) + rte_mempool_put_bulk(pool, + (void *)free, + blk_n); + free[0] = m; + pool = m->pool; + blk_n = 1; + } + } + } + if (blk_n) + rte_mempool_put_bulk(pool, (void *)free, blk_n); #ifndef NDEBUG - /* Poisoning. */ + elts_free = txq->elts_tail; + /* Poisoning. */ + while (elts_free != elts_tail) { memset(&(*txq->elts)[elts_free & elts_m], 0x66, sizeof((*txq->elts)[elts_free & elts_m])); -#endif - RTE_MBUF_PREFETCH_TO_FREE(elt_next); - /* Only one segment needs to be freed. */ - rte_pktmbuf_free_seg(elt); ++elts_free; } +#endif txq->cq_ci = cq_ci; txq->elts_tail = elts_tail; /* Update the consumer index. */ -- 2.11.0