From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: linux-rdma@vger.kernel.org, Artemy Kovalyov <artemyko@mellanox.com>
Subject: Re: [PATCH 6/6] RDMA/mlx5: Add missing synchronize_srcu() for MW cases
Date: Thu, 3 Oct 2019 09:33:42 -0300 [thread overview]
Message-ID: <20191003123342.GA26135@ziepe.ca> (raw)
In-Reply-To: <20191003085449.GN5855@unreal>
On Thu, Oct 03, 2019 at 11:54:49AM +0300, Leon Romanovsky wrote:
> > diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
> > index 3a27bddfcf31f5..630599311586ec 100644
> > +++ b/drivers/infiniband/hw/mlx5/mr.c
> > @@ -1962,14 +1962,25 @@ struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
> >
> > int mlx5_ib_dealloc_mw(struct ib_mw *mw)
> > {
> > + struct mlx5_ib_dev *dev = to_mdev(mw->device);
> > struct mlx5_ib_mw *mmw = to_mmw(mw);
> > int err;
> >
> > - err = mlx5_core_destroy_mkey((to_mdev(mw->device))->mdev,
> > - &mmw->mmkey);
> > - if (!err)
> > - kfree(mmw);
> > - return err;
> > + if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) {
> > + xa_erase(&dev->mdev->priv.mkey_table,
> > + mlx5_base_mkey(mmw->mmkey.key));
> > + /*
> > + * pagefault_single_data_segment() may be accessing mmw under
> > + * SRCU if the user bound an ODP MR to this MW.
> > + */
> > + synchronize_srcu(&dev->mr_srcu);
> > + }
> > +
> > + err = mlx5_core_destroy_mkey(dev->mdev, &mmw->mmkey);
> > + if (err)
> > + return err;
> > + kfree(mmw);
>
> You are skipping kfree() in case of error returned by mlx5_core_destroy_mkey().
> IMHO, it is right for -ENOENT, but is not right for mlx5_cmd_exec() failures.
This is pre-existing behavior, it seems reasonable to always free.
Again, allow error on destroy is such an annoying anti-pattern..
But fixing this should be a followup patch
Jason
next prev parent reply other threads:[~2019-10-03 12:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 15:38 [PATCH -rc 0/6] Bug fixes for odp Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 1/6] RDMA/mlx5: Do not allow rereg of a ODP MR Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 2/6] RDMA/mlx5: Fix a race with mlx5_ib_update_xlt on an implicit MR Jason Gunthorpe
2019-10-02 8:18 ` Leon Romanovsky
2019-10-02 14:39 ` Jason Gunthorpe
2019-10-02 15:41 ` Leon Romanovsky
2019-10-03 12:48 ` Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 3/6] RDMA/odp: Lift umem_mutex out of ib_umem_odp_unmap_dma_pages() Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 4/6] RDMA/mlx5: Order num_pending_prefetch properly with synchronize_srcu Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 5/6] RDMA/mlx5: Put live in the correct place for ODP MRs Jason Gunthorpe
2019-10-01 15:38 ` [PATCH 6/6] RDMA/mlx5: Add missing synchronize_srcu() for MW cases Jason Gunthorpe
2019-10-03 8:54 ` Leon Romanovsky
2019-10-03 12:33 ` Jason Gunthorpe [this message]
2019-10-04 18:55 ` [PATCH -rc 0/6] Bug fixes for odp 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=20191003123342.GA26135@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=artemyko@mellanox.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.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 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).