From: Leon Romanovsky <leon@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@mellanox.com>,
Maor Gottlieb <maorg@mellanox.com>,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-rc v1] RDMA/mlx5: Use xa_lock_irq when access to SRQ table
Date: Tue, 7 Jul 2020 18:37:18 +0300 [thread overview]
Message-ID: <20200707153718.GO207186@unreal> (raw)
In-Reply-To: <20200707134258.GL25523@casper.infradead.org>
On Tue, Jul 07, 2020 at 02:42:58PM +0100, Matthew Wilcox wrote:
> On Tue, Jul 07, 2020 at 04:15:51PM +0300, Leon Romanovsky wrote:
> > +++ b/drivers/infiniband/hw/mlx5/srq_cmd.c
> > @@ -83,11 +83,11 @@ struct mlx5_core_srq *mlx5_cmd_get_srq(struct mlx5_ib_dev *dev, u32 srqn)
> > struct mlx5_srq_table *table = &dev->srq_table;
> > struct mlx5_core_srq *srq;
> >
> > - xa_lock(&table->array);
> > + xa_lock_irq(&table->array);
> > srq = xa_load(&table->array, srqn);
> > if (srq)
> > refcount_inc(&srq->common.refcount);
> > - xa_unlock(&table->array);
> > + xa_unlock_irq(&table->array);
>
> This one is correct.
>
> > @@ -655,11 +655,11 @@ static int srq_event_notifier(struct notifier_block *nb,
> > eqe = data;
> > srqn = be32_to_cpu(eqe->data.qp_srq.qp_srq_n) & 0xffffff;
> >
> > - xa_lock(&table->array);
> > + xa_lock_irq(&table->array);
> > srq = xa_load(&table->array, srqn);
> > if (srq)
> > refcount_inc(&srq->common.refcount);
> > - xa_unlock(&table->array);
> > + xa_unlock_irq(&table->array);
>
> This one is not. srq_event_notifier() is called in irq context, always,
> so leave it as xa_lock() / xa_unlock().
>
> You could switch to a less-locked model, which would look something like this:
>
> rcu_read_lock();
> srq = xa_load(&table->array, srqn);
> if (srq && !refcount_inc_not_zero(&srq->common.refcount))
> srq = NULL;
> rcu_read_unlock();
>
> Then you wouldn't need to disable irqs while accessing the array.
> But you would need to rcu-free the srqs.
Thanks for your feedback,
At this point of time, we don't need rcu_* optimization, it is not
bottleneck yet :).
Thanks
prev parent reply other threads:[~2020-07-07 15:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 13:15 [PATCH rdma-rc v1] RDMA/mlx5: Use xa_lock_irq when access to SRQ table Leon Romanovsky
2020-07-07 13:42 ` Matthew Wilcox
2020-07-07 15:37 ` Leon Romanovsky [this message]
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=20200707153718.GO207186@unreal \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@mellanox.com \
--cc=willy@infradead.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