From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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=HTJieiAX7WajM6qDEnbeRQM5h//FERE4ct6iXE1QdF0=; b=TTnypfzVOBiD6ZpNRCkK7RkQkfZk5o3nQW7BMqOwk0xdCLLkG1+Qa/Yl/d5qu4d/ZH vm3j5VhhVHZ7L1qMm7yGi1A8Rhei670CU1FSwsGAzvOHL2RQElOcf5sIPNEQJzyj/Nx1 VgpKBXfMQ06dtiW9TW6hZFh+3AHxteBH3AJCou5eSfxz3SqoUEOJrlnX70P8sF0lH8T8 3mXbdUZKuX91CTxRa6VDHdS8htfCVZRpihFtFdWCOxSAvQIVcW4fy9NpTBBDPCj+DE/6 6cG06pofYSUh6MJ73d9dziIZ306oDAbJLoCfGL/6A3zQBl97F1TSJT1KH1+dgkZYNk9u FG7A== 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=HTJieiAX7WajM6qDEnbeRQM5h//FERE4ct6iXE1QdF0=; b=cwW42tv9HzWDIwBRWNGiI1xDPULLPkl2UPswK9NjEDy35bBntNlR78daRk9sN1nUG/ p7OT60QO0bLsTuC4s0doiXmhXRW91evZpW6d/5XKWa7hsc4cCy8OESFIAAFYUV16HQX+ ahARF8uqunC0g0nPIOhwG5oaDROUtIJgnwss8yTc28IUWz195MKytSHReahDsV8xU+2t WJ8YqvSA1WfkxaDt0Sw/qKrYyj+7HL5Hm78wf2rP/KDrs/ede1ar50/+AVSdh0Qflf3X QwOtQgnaGlMW4njKHRl4UXfGhzxLE1gAszAKdfqL9yMvfSmvSfEymTgxXgejqwUkKXla x3RA== X-Gm-Message-State: AMCzsaW5OgSIFYolqvfjF1Ul3GaclElCzyhXOG7TEAj3J0FHjI/dgGPK vRqqcRzWIzEmSDqAno00rKKT X-Google-Smtp-Source: AOwi7QDdn+zCz7y8YAhQwLTCHr+5Rx0XQic5nvggLzQVKS9DgffqI6NO+4ktmDMDQbn9Zbpm6PWocA== X-Received: by 10.80.136.81 with SMTP id c17mr2275570edc.13.1507278635561; Fri, 06 Oct 2017 01:30:35 -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 a23sm1306536edj.26.2017.10.06.01.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Oct 2017 01:30:35 -0700 (PDT) Date: Fri, 6 Oct 2017 10:30:24 +0200 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro To: Yongseok Koh Cc: dev@dpdk.org, adrien.mazarguil@6wind.com, ferruh.yigit@intel.com 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171006011125.GA19124@yongseok-MBP.local> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2 09/30] net/mlx5: add reference counter on memory region 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, 06 Oct 2017 08:30:36 -0000 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