linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Parav Pandit <parav@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH rdma-next] IB/core: Avoid deadlock during netlink message handling
Date: Thu, 24 Oct 2019 22:19:47 +0300	[thread overview]
Message-ID: <20191024191947.GV4853@unreal> (raw)
In-Reply-To: <20191024183639.GA23952@ziepe.ca>

On Thu, Oct 24, 2019 at 03:36:39PM -0300, Jason Gunthorpe wrote:
> On Thu, Oct 24, 2019 at 06:28:35PM +0000, Parav Pandit wrote:
> >
> >
> > > From: Leon Romanovsky <leon@kernel.org>
> > > Sent: Thursday, October 24, 2019 11:13 AM
> > > To: Jason Gunthorpe <jgg@ziepe.ca>
> > > Cc: Doug Ledford <dledford@redhat.com>; Parav Pandit
> > > <parav@mellanox.com>; RDMA mailing list <linux-rdma@vger.kernel.org>
> > > Subject: Re: [PATCH rdma-next] IB/core: Avoid deadlock during netlink message
> > > handling
> > >
> > > On Thu, Oct 24, 2019 at 01:08:10PM -0300, Jason Gunthorpe wrote:
> > > > On Thu, Oct 24, 2019 at 07:02:52PM +0300, Leon Romanovsky wrote:
> > > > > On Thu, Oct 24, 2019 at 10:50:17AM -0300, Jason Gunthorpe wrote:
> > > > > > On Thu, Oct 24, 2019 at 04:26:07PM +0300, Leon Romanovsky wrote:
> > > > > > > On Thu, Oct 24, 2019 at 10:17:43AM -0300, Jason Gunthorpe wrote:
> > > > > > > > On Tue, Oct 15, 2019 at 11:07:33AM +0300, Leon Romanovsky wrote:
> > > > > > > >
> > > > > > > > > diff --git a/drivers/infiniband/core/netlink.c
> > > > > > > > > b/drivers/infiniband/core/netlink.c
> > > > > > > > > index 81dbd5f41bed..a3507b8be569 100644
> > > > > > > > > +++ b/drivers/infiniband/core/netlink.c
> > > > > > > > > @@ -42,9 +42,12 @@
> > > > > > > > >  #include <linux/module.h>
> > > > > > > > >  #include "core_priv.h"
> > > > > > > > >
> > > > > > > > > -static DEFINE_MUTEX(rdma_nl_mutex);  static struct {
> > > > > > > > > -	const struct rdma_nl_cbs   *cb_table;
> > > > > > > > > +	const struct rdma_nl_cbs __rcu *cb_table;
> > > > > > > > > +	/* Synchronizes between ongoing netlink commands and
> > > netlink client
> > > > > > > > > +	 * unregistration.
> > > > > > > > > +	 */
> > > > > > > > > +	struct srcu_struct unreg_srcu;
> > > > > > > >
> > > > > > > > A srcu in every index is serious overkill for this. Lets just
> > > > > > > > us a
> > > > > > > > rwsem:
> > > > > > >
> > > > > > > I liked previous variant more than rwsem, but it is Parav's patch.
> > > > > >
> > > > > > Why? srcu is a huge data structure and slow on unregister
> > > > >
> > > > > The unregister time is not so important for those IB/core modules.
> > > > > I liked SRCU because it doesn't have *_ONCE() macros and smb_* calls.
> > > >
> > > > It does, they are just hidden under other macros..
>
> > Its better that they are hidden. So that we don't need open code
> > them.
>
> I wouldn't call swapping one function call for another 'open coding'
>
> > Also with srcu, we don't need lock annotations in get_cb_table()
> > which releases and acquires semaphore.
>
> You don't need lock annoations for that.
>
> > Additionally lock nesting makes overall more complex.
>
> SRCU nesting is just as complicated! Don't think SRCU magically hides
> that issue, it is still proposing to nest SRCU read side sections.
>
> > Given that there are only 3 indices, out of which only 2 are outside
> > of the ib_core module and unlikely to be unloaded, I also prefer
> > srcu version.
>
> Why? It isn't faster, it uses more memory, it still has the same
> complex concurrency arrangement..

Jason,

It doesn't worth arguing, both Parav and I prefer SRCU variant, you
prefer rwsem, so go for it, take rwsem, it is not important.

Thanks

>
> Jason

  reply	other threads:[~2019-10-24 19:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  8:07 [PATCH rdma-next] IB/core: Avoid deadlock during netlink message handling Leon Romanovsky
2019-10-24 13:17 ` Jason Gunthorpe
2019-10-24 13:26   ` Leon Romanovsky
2019-10-24 13:50     ` Jason Gunthorpe
2019-10-24 16:02       ` Leon Romanovsky
2019-10-24 16:08         ` Jason Gunthorpe
2019-10-24 16:13           ` Leon Romanovsky
2019-10-24 18:28             ` Parav Pandit
2019-10-24 18:36               ` Jason Gunthorpe
2019-10-24 19:19                 ` Leon Romanovsky [this message]
2019-10-24 19:53                   ` Parav Pandit
2019-10-24 23:53                     ` Jason Gunthorpe

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=20191024191947.GV4853@unreal \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@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).