DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] common/mlx5: fix MR lookup on slow path
@ 2021-11-25 20:20 Dmitry Kozlyuk
  2021-11-26  8:52 ` Slava Ovsiienko
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-25 20:20 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Raslan Darawsheh, Viacheslav Ovsiienko, Matan Azrad

Memory region (MR) was being looked up incorrectly
for the data address of an externally-attached mbuf.
A search was attempted for the mempool of the mbuf,
while mbuf data address does not belong to this mempool
in case of externally-attached mbuf.
Only attempt the search:
1) for not externally-attached mbufs;
2) for mbufs coming from MPRQ mempool;
3) for externally-attached mbufs from mempools
   with pinned external buffers.

Fixes: 08ac03580ef2 ("common/mlx5: fix mempool registration")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Reviewed-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/mlx5_common_mr.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c
index 01f35ebcdf..c694aaf28c 100644
--- a/drivers/common/mlx5/mlx5_common_mr.c
+++ b/drivers/common/mlx5/mlx5_common_mr.c
@@ -2002,21 +2002,29 @@ mlx5_mr_mb2mr_bh(struct mlx5_mr_ctrl *mr_ctrl, struct rte_mbuf *mb)
 			     dev_gen);
 	struct mlx5_common_device *cdev =
 		container_of(share_cache, struct mlx5_common_device, mr_scache);
+	bool external, mprq, pinned = false;
 
 	/* Recover MPRQ mempool. */
-	if (RTE_MBUF_HAS_EXTBUF(mb) &&
-	    mb->shinfo->free_cb == mlx5_mprq_buf_free_cb) {
+	external = RTE_MBUF_HAS_EXTBUF(mb);
+	if (external && mb->shinfo->free_cb == mlx5_mprq_buf_free_cb) {
+		mprq = true;
 		buf = mb->shinfo->fcb_opaque;
 		mp = buf->mp;
 	} else {
+		mprq = false;
 		mp = mlx5_mb2mp(mb);
+		pinned = rte_pktmbuf_priv_flags(mp) &
+			 RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF;
+	}
+	if (!external || mprq || pinned) {
+		lkey = mlx5_mr_mempool2mr_bh(mr_ctrl, mp, addr);
+		if (lkey != UINT32_MAX)
+			return lkey;
+		/* MPRQ is always registered. */
+		MLX5_ASSERT(!mprq);
 	}
-	lkey = mlx5_mr_mempool2mr_bh(mr_ctrl, mp, addr);
-	if (lkey != UINT32_MAX)
-		return lkey;
 	/* Register pinned external memory if the mempool is not used for Rx. */
-	if (cdev->config.mr_mempool_reg_en &&
-	    (rte_pktmbuf_priv_flags(mp) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF)) {
+	if (cdev->config.mr_mempool_reg_en && pinned) {
 		if (mlx5_mr_mempool_register(cdev, mp, true) < 0)
 			return UINT32_MAX;
 		lkey = mlx5_mr_mempool2mr_bh(mr_ctrl, mp, addr);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] common/mlx5: fix MR lookup on slow path
  2021-11-25 20:20 [PATCH] common/mlx5: fix MR lookup on slow path Dmitry Kozlyuk
@ 2021-11-26  8:52 ` Slava Ovsiienko
  2021-11-26 12:28   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Slava Ovsiienko @ 2021-11-26  8:52 UTC (permalink / raw)
  To: Dmitry Kozlyuk, dev
  Cc: NBU-Contact-Thomas Monjalon (EXTERNAL), Raslan Darawsheh, Matan Azrad

> -----Original Message-----
> From: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Sent: Thursday, November 25, 2021 22:21
> To: dev@dpdk.org
> Cc: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> Raslan Darawsheh <rasland@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Matan Azrad <matan@nvidia.com>
> Subject: [PATCH] common/mlx5: fix MR lookup on slow path
> 
> Memory region (MR) was being looked up incorrectly for the data address of
> an externally-attached mbuf.
> A search was attempted for the mempool of the mbuf, while mbuf data
> address does not belong to this mempool in case of externally-attached mbuf.
> Only attempt the search:
> 1) for not externally-attached mbufs;
> 2) for mbufs coming from MPRQ mempool;
> 3) for externally-attached mbufs from mempools
>    with pinned external buffers.
> 
> Fixes: 08ac03580ef2 ("common/mlx5: fix mempool registration")
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Reviewed-by: Matan Azrad <matan@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] common/mlx5: fix MR lookup on slow path
  2021-11-26  8:52 ` Slava Ovsiienko
@ 2021-11-26 12:28   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2021-11-26 12:28 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, Raslan Darawsheh, Matan Azrad, Slava Ovsiienko

> > Memory region (MR) was being looked up incorrectly for the data address of
> > an externally-attached mbuf.
> > A search was attempted for the mempool of the mbuf, while mbuf data
> > address does not belong to this mempool in case of externally-attached mbuf.
> > Only attempt the search:
> > 1) for not externally-attached mbufs;
> > 2) for mbufs coming from MPRQ mempool;
> > 3) for externally-attached mbufs from mempools
> >    with pinned external buffers.
> > 
> > Fixes: 08ac03580ef2 ("common/mlx5: fix mempool registration")
> > 
> > Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> > Reviewed-by: Matan Azrad <matan@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Applied as last-minute critical fix.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-26 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25 20:20 [PATCH] common/mlx5: fix MR lookup on slow path Dmitry Kozlyuk
2021-11-26  8:52 ` Slava Ovsiienko
2021-11-26 12:28   ` Thomas Monjalon

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).