All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: <zyjzyj2000@gmail.com>, <linux-rdma@vger.kernel.org>,
	Bob Pearson <rpearson@hpe.com>
Subject: Re: [PATCH v2] RDMA/rxe: Use acquire/release for memory ordering
Date: Thu, 10 Dec 2020 19:14:00 -0400	[thread overview]
Message-ID: <20201210231400.GZ552508@nvidia.com> (raw)
In-Reply-To: <20201210174258.5234-1-rpearson@hpe.com>

On Thu, Dec 10, 2020 at 11:42:59AM -0600, Bob Pearson wrote:

> @@ -76,26 +56,56 @@ static inline int next_index(struct rxe_queue *q, int index)
>  
>  static inline int queue_empty(struct rxe_queue *q)
>  {
> -	return ((q->buf->producer_index - q->buf->consumer_index)
> -			& q->index_mask) == 0;
> +	u32 prod;
> +	u32 cons;
> +
> +	/* make sure all changes to queue complete before
> +	 * testing queue empty
> +	 */
> +	prod = smp_load_acquire(&q->buf->producer_index);
> +	/* same */
> +	cons = smp_load_acquire(&q->buf->consumer_index);

This is not so sensible. The one written by the kernel should be just
a normal load and there must be some lock held here to protect that

The one written by user space should be just READ_ONCE

acquire only has meaning if you go on to read additional data based on
the result of the acquire - then acquire ensures the additional reads
can't cross writes that occured before the matching release.

Jason

  reply	other threads:[~2020-12-10 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10 17:42 [PATCH v2] RDMA/rxe: Use acquire/release for memory ordering Bob Pearson
2020-12-10 23:14 ` Jason Gunthorpe [this message]
2020-12-11 23:59 ` 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=20201210231400.GZ552508@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=rpearson@hpe.com \
    --cc=rpearsonhpe@gmail.com \
    --cc=zyjzyj2000@gmail.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 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.