All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH rdma-rc 4/9] IB/mlx4: Don't return errors from poll_cq
Date: Mon, 29 Aug 2016 13:04:34 +0300	[thread overview]
Message-ID: <20160829100434.GD594@leon.nu> (raw)
In-Reply-To: <20160829094119.GB594-2ukJVAZIZ/Y@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4215 bytes --]

On Mon, Aug 29, 2016 at 12:41:19PM +0300, Leon Romanovsky wrote:
> On Sun, Aug 28, 2016 at 07:05:51PM +0300, Sagi Grimberg wrote:
> >
> > > 		/* SRQ is also in the radix tree */
> > > 		msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev,
> > > 				       srq_num);
> > >-		if (unlikely(!msrq)) {
> > >-			pr_warn("CQ %06x with entry for unknown SRQN %06x\n",
> > >-				cq->mcq.cqn, srq_num);
> > >-			return -EINVAL;
> > >-		}
> > > 	}
> >
> > BTW, this is completely unrelated to this patch, but the current
> > implementation of shared receive queues in Mellanox drivers is
> > *very* inefficient. Each completion that relates to a srq the
> > mlx4/mlx5 drivers perform a device-wide locked srq lookup which
> > is pretty bad... (it kills consumers that want to use more
> > then one SRQ)
> >
> > Other drivers that support kernel SRQs that I've looked at are ocrdma and
> > i40iw and they don't seem to have this lock everything approach.
> >
> > At the very-least we should try to make it a rcu + percpu_ref
> > instead of a killer device-wide lock. It'd be even better if
> > we use refcounting in the IB core and have the drivers not worry
> > about the kernel consumers destroying SRQs while processing IO
> > (i.e. when all the related QPs and CQs are destroyed).
>
> This can be as a beginning.
> diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
> index 6714662..e53d366 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/srq.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
> @@ -303,10 +303,10 @@ struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn)
>  	struct mlx4_srq *srq;
>  	unsigned long flags;
>
> -	spin_lock_irqsave(&srq_table->lock, flags);
> +	rcu_read_lock();
>  	srq = radix_tree_lookup(&srq_table->tree,
>  				srqn & (dev->caps.num_srqs - 1));
> -	spin_unlock_irqrestore(&srq_table->lock, flags);
> +	rcu_read_unlock();
>
>  	return srq;
>  }

Or more complete patch (untested),

From 8695e5b807610e08de055b04ddd16caa6a5b61f2 Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Date: Mon, 29 Aug 2016 12:42:24 +0300
Subject: [PATCH] IB/mlx4: Use RCU to perform radix tree lookup for SRQ

Radix tree lookup can be performed without locking.

Suggested-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Signed-off-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx4/srq.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
index 6714662..f44d089 100644
--- a/drivers/net/ethernet/mellanox/mlx4/srq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
@@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
 	struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
 	struct mlx4_srq *srq;

-	spin_lock(&srq_table->lock);
-
+	rcu_read_lock();
 	srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1));
+	rcu_read_unlock();
 	if (srq)
 		atomic_inc(&srq->refcount);
-
-	spin_unlock(&srq_table->lock);
-
-	if (!srq) {
+	else {
 		mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
 		return;
 	}
@@ -301,12 +298,11 @@ struct mlx4_srq *mlx4_srq_lookup(struct mlx4_dev *dev, u32 srqn)
 {
 	struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
 	struct mlx4_srq *srq;
-	unsigned long flags;

-	spin_lock_irqsave(&srq_table->lock, flags);
+	rcu_read_lock();
 	srq = radix_tree_lookup(&srq_table->tree,
 				srqn & (dev->caps.num_srqs - 1));
-	spin_unlock_irqrestore(&srq_table->lock, flags);
+	rcu_read_unlock();

 	return srq;
 }
--
2.7.4


>
> >
> > I have some code in the works on this but it's not high on my todo
> > list at the moment. Mellanox folks, any thoughts on this?
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2016-08-29 10:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28  7:58 [PATCH rdma-rc 0/9] RDMA fixes for 4.8 Leon Romanovsky
     [not found] ` <1472371118-8260-1-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-08-28  7:58   ` [PATCH rdma-rc 1/9] IB/core: Fix use after free in send_leave function Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 2/9] IB/ipoib: Fix memory corruption during ipoib cm connection establishment Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 3/9] Revert "IB/mlx4: Return EAGAIN for any error in mlx4_ib_poll_one" Leon Romanovsky
     [not found]     ` <1472371118-8260-4-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-08-28  8:09       ` Yuval Shaia
2016-08-28  8:32         ` Leon Romanovsky
2016-08-28 17:17       ` Jason Gunthorpe
     [not found]         ` <20160828171758.GA11719-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-08-28 18:26           ` Leon Romanovsky
     [not found]             ` <20160828182613.GP594-2ukJVAZIZ/Y@public.gmane.org>
2016-08-28 18:27               ` Leon Romanovsky
2016-08-28 18:28               ` Jason Gunthorpe
     [not found]                 ` <20160828182813.GB12783-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-08-28 18:35                   ` Leon Romanovsky
     [not found]                     ` <20160828183500.GQ594-2ukJVAZIZ/Y@public.gmane.org>
2016-08-28 18:39                       ` Jason Gunthorpe
2016-09-02 18:03                       ` Doug Ledford
     [not found]                         ` <aa325795-a120-6dee-a102-6aaa903be617-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-09-04  6:14                           ` Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 4/9] IB/mlx4: Don't return errors from poll_cq Leon Romanovsky
     [not found]     ` <1472371118-8260-5-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-08-28 16:05       ` Sagi Grimberg
     [not found]         ` <82f1a1be-1189-c8c6-b134-d2f582cc7fa0-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-08-29  9:41           ` Leon Romanovsky
     [not found]             ` <20160829094119.GB594-2ukJVAZIZ/Y@public.gmane.org>
2016-08-29 10:04               ` Leon Romanovsky [this message]
     [not found]                 ` <20160829100434.GD594-2ukJVAZIZ/Y@public.gmane.org>
2016-09-04  6:17                   ` Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 5/9] IB/mlx5: Return EINVAL when caller specifies too many SGEs Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 6/9] IB/mlx5: Simplify code by removing return variable Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 7/9] IB/mlx5: Add VERBOSITY Kconfig option Leon Romanovsky
     [not found]     ` <1472371118-8260-8-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-02 17:52       ` Doug Ledford
     [not found]         ` <55889fa6-51c0-fcf6-7684-9712b82212d6-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-09-04  8:26           ` Leon Romanovsky
2016-08-28  7:58   ` [PATCH rdma-rc 8/9] IB/mlx5: Use TIR number based on selector Leon Romanovsky
     [not found]     ` <1472371118-8260-9-git-send-email-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-08-28 15:47       ` Sagi Grimberg
2016-08-28  7:58   ` [PATCH rdma-rc 9/9] IB/mlx5: Don't return errors from poll_cq Leon Romanovsky
2016-09-02 18:13   ` [PATCH rdma-rc 0/9] RDMA fixes for 4.8 Doug Ledford
     [not found]     ` <d5eff78f-0014-e748-11c9-888c70542391-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-09-04  8:27       ` Leon Romanovsky

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=20160829100434.GD594@leon.nu \
    --to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.