From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 7EAA8235 for ; Fri, 30 Jun 2017 14:43:31 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id r103so203893524wrb.0 for ; Fri, 30 Jun 2017 05:43:31 -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=40HGDa1CtlX3pDDiBQBZOTTPN2JDhy1MBkOTJ8wFW18=; b=X9TpaT8qMilfUyUWxoTHso69dp9Ogh86pOzWUiIG474HDNtJPvotr30ey/QXWZfwVq sEoE9F1jxBxSRp/wFjJCe1mlPVgSXTHAiPYDlCI8Cbpp5438q6DXvHY82knfsczPKFeH ldnV7YLwgeUuZkDCYoQXRDkpE5IboNDWGHCQQuD8lp1cSiGnPjiYHqDLqfI8U1Ohz3RZ ubDwVzAG5EgPqBq3hD9O04sRkoq+7D2f3yqxyWtdAeyDPqqo8LpqpMIV5391fugzArxN 834bR6ROwjISmxJ9WkTkPI7BeJmJg5axCCKuq+qwecAhNuIr9k6HJdM5SkYQS3w1QEG2 Nk+Q== 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=40HGDa1CtlX3pDDiBQBZOTTPN2JDhy1MBkOTJ8wFW18=; b=qTtq8FfAzSsVGHLnwdJe2g8UEWzFGTqQQHUVOICTI/MNntXihadwx0gyV0b1sRe2vf T1Fxz/V8SukQGaOQ4/+Rerenpvl5ZRYyKvo/Zz2AX7SCP9BRLAG5FqvEFiv5LnZG2nCf 2LXazHWu4s59q73BNBQiQmnn3F0k/FVQ82QGN+WitnGVW86NT9pNbxfdA34l9pGRY7RV 8wCvna2CJteZ70is/qFGi075dMIeryiBxfiMfnIM3icnh/WHWzhmHHmJaO4WDGZY/cFY ephA4ysp7vcMuA5YjC18ZQJKnhIyudeMpFt1xiJ1p4+uhUslfpFsu7tu9qOPpnX3ML7z NWLA== X-Gm-Message-State: AKS2vOwZ4DS9nR4Crk4/vhKqYO1jpKLikzr2pa6uf+fKxjpwRM3QYRSO xK0esLDbWuEhzkYy X-Received: by 10.223.133.186 with SMTP id 55mr28783122wrt.102.1498826609956; Fri, 30 Jun 2017 05:43:29 -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 b94sm6664777wrd.40.2017.06.30.05.43.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 05:43:29 -0700 (PDT) Date: Fri, 30 Jun 2017 14:43:21 +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: <20170630124321.GP18305@autoinstall.dev.6wind.com> References: <20170628230403.10142-1-yskoh@mellanox.com> <20170628230403.10142-3-yskoh@mellanox.com> <20170630123047.GO18305@autoinstall.dev.6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170630123047.GO18305@autoinstall.dev.6wind.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:43:32 -0000 On Fri, Jun 30, 2017 at 02:30:47PM +0200, Nélio Laranjeiro wrote: > 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)) { This condition is a wrong also, it should be !blk_n || (m->pool ... Why don't you keep a pointer to the mpool (e.g. m->pool == pool)? It seems to cost a little to deference two pointers to reach the pool's one. Thanks, -- Nélio Laranjeiro 6WIND