DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@mellanox.com>
To: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Cc: Xueming Li <xuemingl@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	 dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/4] net/mlx5: remove MR refcnt
Date: Mon, 15 Jan 2018 14:54:20 +0800	[thread overview]
Message-ID: <20180115065420.44065-4-xuemingl@mellanox.com> (raw)
In-Reply-To: <20180115065420.44065-1-xuemingl@mellanox.com>

MRs are registered to priv at device start or on the fly, destroyied
when device stop.
No mR registration to perticular TXQ, MR references cache in TXQ just
part of device MR list, no reason to keep MR refcnt.

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5.h      |  1 -
 drivers/net/mlx5/mlx5_mr.c   | 51 +++++---------------------------------------
 drivers/net/mlx5/mlx5_rxq.c  |  1 -
 drivers/net/mlx5/mlx5_rxtx.h |  2 --
 drivers/net/mlx5/mlx5_txq.c  | 18 ----------------
 5 files changed, 5 insertions(+), 68 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index a6cd1474c..df6a70d96 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -318,7 +318,6 @@ int priv_socket_connect(struct priv *priv);
 
 struct mlx5_mr *priv_mr_new(struct priv *priv, struct rte_mempool *mp,
 			    uintptr_t addr);
-struct mlx5_mr *priv_mr_get(struct priv *, struct rte_mempool *);
 int priv_mr_release(struct priv *, struct mlx5_mr *);
 int priv_mr_verify(struct priv *);
 struct mlx5_mr *priv_mr_lookup(struct priv *priv, uintptr_t addr);
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 8d8fabea1..bd1be5606 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -88,15 +88,11 @@ mlx5_mempool_register_cb(struct rte_mempool *mp, void *opaque,
 		cb->error = -1;
 		return;
 	}
-	mr->mp = mp;
 	DEBUG("mempool %p:%u area start=%p size=%zu lkey=0x%08x",
 	      (void *)mp, mem_idx, memhdr->addr, memhdr->len, mr->mr->lkey);
 	mr->lkey = rte_cpu_to_be_32(mr->mr->lkey);
 	mr->start = (uintptr_t)memhdr->addr;
 	mr->end = (uintptr_t)mr->mr->addr + mr->mr->length;
-	rte_atomic32_inc(&mr->refcnt);
-	DEBUG("%p: new Memory Region %p refcnt: %d", (void *)priv,
-	      (void *)mr, rte_atomic32_read(&mr->refcnt));
 	LIST_INSERT_HEAD(&priv->mr, mr, next);
 	cb->mr = mr;
 }
@@ -121,11 +117,8 @@ mlx5_mp2mr(struct priv *priv, struct rte_mempool *mp, uintptr_t addr)
 
 	priv_lock(priv);
 	mr = priv_mr_lookup(priv, addr);
-	if (!mr) {
+	if (!mr)
 		mr = priv_mr_new(priv, mp, addr);
-		if (mr)
-			rte_atomic32_inc(&mr->refcnt);
-	}
 	priv_unlock(priv);
 	return mr;
 }
@@ -217,35 +210,6 @@ priv_mr_new(struct priv *priv, struct rte_mempool *mp, uintptr_t addr)
 }
 
 /**
- * Search the memory region object in the memory region list.
- *
- * @param  priv
- *   Pointer to private structure.
- * @param mp
- *   Pointer to the memory pool to register.
- * @return
- *   The memory region on success.
- */
-struct mlx5_mr*
-priv_mr_get(struct priv *priv, struct rte_mempool *mp)
-{
-	struct mlx5_mr *mr;
-
-	assert(mp);
-	if (LIST_EMPTY(&priv->mr))
-		return NULL;
-	LIST_FOREACH(mr, &priv->mr, next) {
-		if (mr->mp == mp) {
-			rte_atomic32_inc(&mr->refcnt);
-			DEBUG("Memory Region %p refcnt: %d",
-			      (void *)mr, rte_atomic32_read(&mr->refcnt));
-			return mr;
-		}
-	}
-	return NULL;
-}
-
-/**
  * Release the memory region object.
  *
  * @param  mr
@@ -259,15 +223,10 @@ priv_mr_release(struct priv *priv, struct mlx5_mr *mr)
 {
 	(void)priv;
 	assert(mr);
-	DEBUG("Memory Region %p refcnt: %d",
-	      (void *)mr, rte_atomic32_read(&mr->refcnt));
-	if (rte_atomic32_dec_and_test(&mr->refcnt)) {
-		claim_zero(ibv_dereg_mr(mr->mr));
-		LIST_REMOVE(mr, next);
-		rte_free(mr);
-		return 0;
-	}
-	return EBUSY;
+	claim_zero(ibv_dereg_mr(mr->mr));
+	LIST_REMOVE(mr, next);
+	rte_free(mr);
+	return 0;
 }
 
 /**
diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index a581a2d61..461b4ff91 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -852,7 +852,6 @@ mlx5_priv_rxq_ibv_get(struct priv *priv, uint16_t idx)
 		return NULL;
 	rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq);
 	if (rxq_ctrl->ibv) {
-		priv_mr_get(priv, rxq_data->mp);
 		rte_atomic32_inc(&rxq_ctrl->ibv->refcnt);
 		DEBUG("%p: Verbs Rx queue %p: refcnt %d", (void *)priv,
 		      (void *)rxq_ctrl->ibv,
diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index 6589a662e..0b8332cc0 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -85,12 +85,10 @@ struct priv;
 /* Memory region queue object. */
 struct mlx5_mr {
 	LIST_ENTRY(mlx5_mr) next; /**< Pointer to the next element. */
-	rte_atomic32_t refcnt; /*<< Reference counter. */
 	uint32_t lkey; /*<< rte_cpu_to_be_32(mr->lkey) */
 	uintptr_t start; /* Start address of MR */
 	uintptr_t end; /* End address of MR */
 	struct ibv_mr *mr; /*<< Memory Region. */
-	struct rte_mempool *mp; /*<< Memory Pool. */
 };
 
 /* Compressed CQE context. */
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index 26db15a4f..3c337a4ac 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -801,18 +801,7 @@ mlx5_priv_txq_get(struct priv *priv, uint16_t idx)
 	if ((*priv->txqs)[idx]) {
 		ctrl = container_of((*priv->txqs)[idx], struct mlx5_txq_ctrl,
 				    txq);
-		unsigned int i;
-
 		mlx5_priv_txq_ibv_get(priv, idx);
-		for (i = 0; i != MLX5_PMD_TX_MP_CACHE; ++i) {
-			struct mlx5_mr *mr = NULL;
-
-			(void)mr;
-			if (ctrl->txq.mp2mr[i]) {
-				mr = priv_mr_get(priv, ctrl->txq.mp2mr[i]->mp);
-				assert(mr);
-			}
-		}
 		rte_atomic32_inc(&ctrl->refcnt);
 		DEBUG("%p: Tx queue %p: refcnt %d", (void *)priv,
 		      (void *)ctrl, rte_atomic32_read(&ctrl->refcnt));
@@ -834,7 +823,6 @@ mlx5_priv_txq_get(struct priv *priv, uint16_t idx)
 int
 mlx5_priv_txq_release(struct priv *priv, uint16_t idx)
 {
-	unsigned int i;
 	struct mlx5_txq_ctrl *txq;
 
 	if (!(*priv->txqs)[idx])
@@ -849,12 +837,6 @@ mlx5_priv_txq_release(struct priv *priv, uint16_t idx)
 		if (!ret)
 			txq->ibv = NULL;
 	}
-	for (i = 0; i != MLX5_PMD_TX_MP_CACHE; ++i) {
-		if (txq->txq.mp2mr[i]) {
-			priv_mr_release(priv, txq->txq.mp2mr[i]);
-			txq->txq.mp2mr[i] = NULL;
-		}
-	}
 	if (rte_atomic32_dec_and_test(&txq->refcnt)) {
 		txq_free_elts(txq);
 		LIST_REMOVE(txq, next);
-- 
2.13.3

  parent reply	other threads:[~2018-01-15  7:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  6:54 [dpdk-dev] [PATCH 1/4] net/mlx5: revert "fix Memory Region registration" Xueming Li
2018-01-15  6:54 ` [dpdk-dev] [PATCH 2/4] net/mlx5: forbid MR registration in secondary process Xueming Li
2018-01-15 15:33   ` Nélio Laranjeiro
2018-01-15  6:54 ` [dpdk-dev] [PATCH 3/4] net/mlx5: support mempool of multi-mem segments Xueming Li
2018-01-15 16:29   ` Nélio Laranjeiro
2018-01-15  6:54 ` Xueming Li [this message]
2018-01-16  8:09   ` [dpdk-dev] [PATCH 4/4] net/mlx5: remove MR refcnt Nélio Laranjeiro
2018-01-15 15:26 ` [dpdk-dev] [PATCH 1/4] net/mlx5: revert "fix Memory Region registration" Nélio Laranjeiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180115065420.44065-4-xuemingl@mellanox.com \
    --to=xuemingl@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=shahafs@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).