From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 096155323 for ; Fri, 30 Jun 2017 14:30:56 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id k67so203003322wrc.2 for ; Fri, 30 Jun 2017 05:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=yiKgJG6vfHdeyJar5S+7/lk3BfvUftpAaC3zcm9B6NA=; b=h9ccMBIpRvt5ReUtWLP7oJ5hv2ffznksMp4nIYt34B4iMacwjm1EgfX7Q8mLZY3bcV ZV1n7wOsedrWEQI4KG8xbwmvjh3k3UcXT5OvcqgiW32Jxl/Fv0gUAi0IeS8jkZmVUyuE 7ZB8jXnqJUGPDtDYKMZh2OIKoIhAspxYsqAJthf9PzOA8YoDvWX9ZC7n9SnaAR5I5osC qQ9NlY23u2BavPr6/ag5eIKrbDRf4+op0H7nZOsHahIYRvMzi5nBFYXygYS2EALif5ZG TD8Aanh6NYJl+1WP3k9XzhLwTO4OkaG9t4QGfoDQeMfMjaDraiA43KoQBCMRWaEoEKK+ j0BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=yiKgJG6vfHdeyJar5S+7/lk3BfvUftpAaC3zcm9B6NA=; b=GER9STx/cgZvh4aX0vJc05qgD0l9RLcwjDihhiAf4ZTzGK9OdTFW2hVqYxxN4fyKao XBt7gixdikOLyLuqoyaOG7lyeADqiAR33VspIWt3Ysxlb8yzm6j16WwlKWxtuZec2UIz /RVSlITzBSiNLa81qSWtsfHZjNLrQ+3JMjv5TYhOINgImdw6dGp50j24FKtBgC6n7GPb np9Y4SkK4KVN98OJ7lPc+zz2kMW/LpetYK+koGW//krv7a42U2b8xeE0bCX9U6QVikO+ c927pRN++Wi9eqP09NDdqYU4oSnSEkIY97bcvgnhLhZ4+s1+oDo/OSPTDsCFaKYzAHfZ fCAw== X-Gm-Message-State: AKS2vOz4P0yVWuUgkmcsp4do9Ur3Y818bP97aOeY1z4TnwzjN6XPMqFW dLrngso0tUEuFoQ4 X-Received: by 10.223.150.10 with SMTP id b10mr29037410wra.149.1498825856550; Fri, 30 Jun 2017 05:30:56 -0700 (PDT) Received: from autoinstall.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id i67sm8234414wri.61.2017.06.30.05.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 05:30:56 -0700 (PDT) Date: Fri, 30 Jun 2017 14:30:47 +0200 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro To: Yongseok Koh Cc: ferruh.yigit@intel.com, dev@dpdk.org, adrien.mazarguil@6wind.com Message-ID: <20170630123047.GO18305@autoinstall.dev.6wind.com> References: <20170628230403.10142-1-yskoh@mellanox.com> <20170628230403.10142-3-yskoh@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170628230403.10142-3-yskoh@mellanox.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH 2/5] net/mlx5: free buffers in bulk on Tx completion X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jun 2017 12:30:57 -0000 On Wed, Jun 28, 2017 at 04:04:00PM -0700, Yongseok Koh wrote: > 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 | 36 +++++++++++++++++++++++++++--------- > 1 file changed, 27 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > index 43db06ad8..d81d630f7 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.c > +++ b/drivers/net/mlx5/mlx5_rxtx.c > @@ -264,6 +264,8 @@ 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]; > + unsigned int blk_n = 0; > > do { > volatile struct mlx5_cqe *tmp; > @@ -296,21 +298,37 @@ 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 (blk_n) { > + if (likely(m->pool == free[0]->pool)) { > + free[blk_n++] = m; > + } else { > + rte_mempool_put_bulk( > + free[0]->pool, > + (void *)free, > + blk_n); The indentation is strange here, free[0] should be on the same line as rte_mempool_put_bulk. > + free[0] = m; > + blk_n = 1; > + } > + } else { > + free[0] = m; > + blk_n = 1; > + } > + } This loop could be smaller, blk_n can only be equal to 0 in the first iteration, otherwise is >= 1. The first if statement can be merged with the second one: if (likely(m != NULL)) { if (likely(blk_n && m->pool == free[0]->pool)) { ... } else { ... } Thanks, -- Nélio Laranjeiro 6WIND