From: Jason Gunthorpe <jgg@nvidia.com>
To: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
Cc: dledford@redhat.com, linux-rdma@vger.kernel.org,
TOTE Robot <oslab@tsinghua.edu.cn>,
Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Subject: Re: [PATCH for-next] IB/hfi1: Fix abba locking issue with sc_disable()
Date: Wed, 13 Oct 2021 13:33:13 -0300 [thread overview]
Message-ID: <20211013163313.GA3468235@nvidia.com> (raw)
In-Reply-To: <20211013141852.128104.2682.stgit@awfm-01.cornelisnetworks.com>
On Wed, Oct 13, 2021 at 10:18:52AM -0400, Dennis Dalessandro wrote:
> From: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
>
> sc_disable() after having disabled the send context wakes up
> any waiters by calling hfi1_qp_wakeup() while holding the
> waitlock for the sc.
>
> This is contrary to the model for all other calls to hfi1_qp_wakeup()
> where the waitlock is dropped and a local is used to drive calls
> to hfi1_qp_wakeup().
>
> Fix by moving the sc->piowait into a local list and driving the wakeup
> calls from the list.
>
> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
> drivers/infiniband/hw/hfi1/pio.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
> index 489b436..3d42bd2 100644
> +++ b/drivers/infiniband/hw/hfi1/pio.c
> @@ -878,6 +878,7 @@ void sc_disable(struct send_context *sc)
> {
> u64 reg;
> struct pio_buf *pbuf;
> + LIST_HEAD(wake_list);
>
> if (!sc)
> return;
> @@ -912,19 +913,21 @@ void sc_disable(struct send_context *sc)
> spin_unlock(&sc->release_lock);
>
> write_seqlock(&sc->waitlock);
> - while (!list_empty(&sc->piowait)) {
> + if (!list_empty(&sc->piowait))
> + list_move(&sc->piowait, &wake_list);
> + write_sequnlock(&sc->waitlock);
> + while (!list_empty(&wake_list)) {
> struct iowait *wait;
> struct rvt_qp *qp;
> struct hfi1_qp_priv *priv;
>
> - wait = list_first_entry(&sc->piowait, struct iowait, list);
> + wait = list_first_entry(&wake_list, struct iowait, list);
> qp = iowait_to_qp(wait);
> priv = qp->priv;
> list_del_init(&priv->s_iowait.list);
> priv->s_iowait.lock = NULL;
> hfi1_qp_wakeup(qp, RVT_S_WAIT_PIO | HFI1_S_WAIT_PIO_DRAIN);
> }
> - write_sequnlock(&sc->waitlock);
clangd tells me there is no read side to this seqlock? Why is it a
seqlock if everything is a write side? Indeed I was wondering because
I don't know of any seq lock safe algorithm for list manipulation -
but it turns out this is just an obfuscated spinlock. Please send a
patch to fix it.
Applied to for-rc
Thanks,
Jason
prev parent reply other threads:[~2021-10-13 16:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 14:18 [PATCH for-next] IB/hfi1: Fix abba locking issue with sc_disable() Dennis Dalessandro
2021-10-13 16:33 ` Jason Gunthorpe [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=20211013163313.GA3468235@nvidia.com \
--to=jgg@nvidia.com \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=dledford@redhat.com \
--cc=linux-rdma@vger.kernel.org \
--cc=mike.marciniszyn@cornelisnetworks.com \
--cc=oslab@tsinghua.edu.cn \
/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.