From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro Subject: Re: [PATCH v2 09/30] net/mlx5: add reference counter on memory region Date: Fri, 6 Oct 2017 10:30:24 +0200 Message-ID: <20171006083024.GO15330@autoinstall.dev.6wind.com> References: <20171006011125.GA19124@yongseok-MBP.local> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org, adrien.mazarguil@6wind.com, ferruh.yigit@intel.com To: Yongseok Koh Return-path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id DFAAA1B22F for ; Fri, 6 Oct 2017 10:30:35 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id t69so6122119wmt.2 for ; Fri, 06 Oct 2017 01:30:35 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20171006011125.GA19124@yongseok-MBP.local> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Oct 05, 2017 at 06:11:26PM -0700, Yongseok Koh wrote: > On Thu, Oct 05, 2017 at 02:49:41PM +0200, Nelio Laranjeiro wrote: > [...] > > @@ -180,12 +133,14 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp, > > { > > struct mlx5_txq_ctrl *txq_ctrl = > > container_of(txq, struct mlx5_txq_ctrl, txq); > > - struct ibv_mr *mr; > > + struct mlx5_mr *mr; > > > > /* Add a new entry, register MR first. */ > > DEBUG("%p: discovered new memory pool \"%s\" (%p)", > > (void *)txq_ctrl, mp->name, (void *)mp); > > - mr = mlx5_mp2mr(txq_ctrl->priv->pd, mp); > > + mr = priv_mr_get(txq_ctrl->priv, mp); > > + if (mr == NULL) > > + mr = priv_mr_new(txq_ctrl->priv, mp); > > if (unlikely(mr == NULL)) { > > DEBUG("%p: unable to configure MR, ibv_reg_mr() failed.", > > (void *)txq_ctrl); > > @@ -196,20 +151,17 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp, > > DEBUG("%p: MR <-> MP table full, dropping oldest entry.", > > (void *)txq_ctrl); > > --idx; > > - claim_zero(ibv_dereg_mr(txq_ctrl->txq.mp2mr[0].mr)); > > + priv_mr_release(txq_ctrl->priv, txq_ctrl->txq.mp2mr[0]); > In this function, txq_ctrl->txq can be replaced with txq. Indeed, >[...] > > } > > txq->mr_cache_idx = 0; > > - return mlx5_txq_mp2mr_reg(txq, mlx5_tx_mb2mp(mb), i); > > + lkey = mlx5_txq_mp2mr_reg(txq, mlx5_tx_mb2mp(mb), i); > > + /* > > + * Request the reference to use in this queue, the original one is > > + * kept by the control plane. > > + */ > > + if (lkey != (uint32_t)-1) > > + rte_atomic32_inc(&txq->mp2mr[i]->refcnt); > If mp2mr is overflowed (i == RTE_DIM(txq->mp2mr)), then mp2mr[0] will be removed > with shifting other slots and the new entry will be added at the end. But > referencing txq->mp2mr[i] would be illegal - out of range. You are right, I missed that one, Both will be updated in a v3, Thanks, -- Nélio Laranjeiro 6WIND