linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Doug Ledford <dledford@redhat.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jason Gunthorpe <jgg@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Saeed Mahameed <saeedm@mellanox.com>
Subject: Re: [PATCH rdma-rc] RDMA/mlx5: Release locks during notifier unregister
Date: Thu, 01 Aug 2019 12:42:43 -0400	[thread overview]
Message-ID: <5ffad7827bc72b43948fa7c4707348999434009a.camel@redhat.com> (raw)
In-Reply-To: <20190801162356.GV4832@mtr-leonro.mtl.com>

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

On Thu, 2019-08-01 at 19:23 +0300, Leon Romanovsky wrote:
> On Thu, Aug 01, 2019 at 12:11:20PM -0400, Doug Ledford wrote:
> > On Thu, 2019-08-01 at 18:59 +0300, Leon Romanovsky wrote:
> > > > There's no need for a lockdep.  The removal of the notifier
> > > > callback
> > > > entry is re-entrant safe.  The core removal routines have their
> > > > own
> > > > spinlock they use to protect the actual notifier list.  If you
> > > > call
> > > > it
> > > > more than once, the second and subsequent calls merely scan the
> > > > list,
> > > > find no matching entry, and return ENOENT.  The only reason this
> > > > might
> > > > need a lock and a lockdep entry is if you are protecting against
> > > > a
> > > > race
> > > > with the *add* notifier code in the mlx5 driver specifically
> > > > (the
> > > > core
> > > > add code won't have an issue, but since you only have a single
> > > > place
> > > > to
> > > > store the notifier callback pointer, if it would be possible for
> > > > you
> > > > to
> > > > add two callbacks and write over the first callback pointer with
> > > > the
> > > > second without removing the first, then you would leak a
> > > > callback
> > > > notifier in the core notifier list).
> > > 
> > > atomic_notifier_chain_unregister() unconditionally calls to
> > > syncronize_rcu() and I'm not so sure that it is best thing to do
> > > for every port unbind.
> > > 
> > > Actually, I'm completely lost here, we are all agree that the
> > > patch
> > > fixes issue correctly, and it returns the code to be exactly as
> > > it was before commit df097a278c75 ("IB/mlx5: Use the new mlx5 core
> > > notifier
> > > API"). Can we simply merge it and fix the kernel panic?
> > 
> > As long as you are OK with me adding a comment to the patch so
> > people
> > coming back later won't scratch their head about how can it possible
> > be
> > right to do that sequence without a lock held, I'm fine merging the
> > fix.
> > 
> > Something like:
> > 
> > /*
> >  * The check/unregister/set-NULL sequence below does not need to be
> >  * locked for correctness as it's only an optimization, and can't
> >  * be under a lock or will throw a scheduling while atomic error.
> >  */
> 
> I think that the best place will be in commit message for this
> explanation,
> but I'm fine with the comment inside code as well.
> 
> Thanks a lot, I appreciate it.

Patch (unmodified) is applied to for-rc, thanks.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
    Fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-08-01 16:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31  8:38 [PATCH rdma-rc] RDMA/mlx5: Release locks during notifier unregister Leon Romanovsky
2019-07-31 16:22 ` Doug Ledford
2019-07-31 17:00   ` Jason Gunthorpe
2019-07-31 17:09     ` Leon Romanovsky
2019-07-31 17:22       ` Jason Gunthorpe
2019-07-31 18:01         ` Leon Romanovsky
2019-07-31 18:51           ` Doug Ledford
2019-08-01  8:22             ` Leon Romanovsky
2019-07-31 19:55           ` Jason Gunthorpe
2019-08-01  8:27             ` Leon Romanovsky
2019-08-01 12:00               ` Jason Gunthorpe
2019-08-01 12:08                 ` Leon Romanovsky
2019-08-01 14:16                   ` Doug Ledford
2019-08-01 15:59                     ` Leon Romanovsky
2019-08-01 16:11                       ` Doug Ledford
2019-08-01 16:20                         ` Jason Gunthorpe
2019-08-01 16:40                           ` Doug Ledford
2019-08-01 16:43                             ` Jason Gunthorpe
2019-08-01 16:50                               ` Doug Ledford
2019-08-01 17:31                                 ` Leon Romanovsky
2019-08-01 16:23                         ` Leon Romanovsky
2019-08-01 16:42                           ` Doug Ledford [this message]
2019-08-01 17:33                             ` Leon Romanovsky
2019-08-01 20:09                               ` Doug Ledford

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=5ffad7827bc72b43948fa7c4707348999434009a.camel@redhat.com \
    --to=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=saeedm@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).