From: Jason Gunthorpe <jgg@nvidia.com>
To: Haakon Bugge <haakon.bugge@oracle.com>
Cc: Doug Ledford <dledford@redhat.com>,
Leon Romanovsky <leon@kernel.org>,
OFED mailing list <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops
Date: Mon, 21 Jun 2021 12:32:55 -0300 [thread overview]
Message-ID: <20210621153255.GR1002214@nvidia.com> (raw)
In-Reply-To: <B57F3E25-B24A-41E8-9CA3-6BA83E378746@oracle.com>
On Mon, Jun 21, 2021 at 03:30:14PM +0000, Haakon Bugge wrote:
>
>
> > On 21 Jun 2021, at 16:35, Jason Gunthorpe <jgg@nvidia.com> wrote:
> >
> > On Wed, Jun 16, 2021 at 04:35:53PM +0200, Håkon Bugge wrote:
> >> +#define BIT_ACCESS_FUNCTIONS(b) \
> >> + static inline void set_##b(unsigned long flags) \
> >> + { \
> >> + /* set_bit() does not imply a memory barrier */ \
> >> + smp_mb__before_atomic(); \
> >> + set_bit(b, &flags); \
> >> + /* set_bit() does not imply a memory barrier */ \
> >> + smp_mb__after_atomic(); \
> >> + }
> >
> > This isn't needed, set_bit/test_bit are already atomic with
> > themselves, we should not need to introduce release semantics.
>
> They are atomic, yes. But set_bit() does not provide a memory barrier (on x86_64, yes, but not as per the Linux definition of set_bit()).
>
> We have (paraphrased):
>
> id_priv->min_rnr_timer = min_rnr_timer;
> set_bit(MIN_RNR_TIMER_SET, &id_priv->flags);
>
> Since set_bit() does not provide a memory barrier, another thread
> may observe the MIN_RNR_TIMER_SET bit in id_priv->flags, but the
> id_priv->min_rnr_timer value is not yet globally visible. Hence,
> IMHO, we need the memory barriers.
No, you need proper locks.
Jason
next prev parent reply other threads:[~2021-06-21 15:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 14:35 [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops Håkon Bugge
2021-06-16 15:02 ` Stefan Metzmacher
2021-06-16 16:03 ` Haakon Bugge
2021-06-17 6:51 ` Leon Romanovsky
2021-06-17 6:56 ` Haakon Bugge
2021-06-17 7:38 ` Leon Romanovsky
2021-06-17 9:19 ` Haakon Bugge
2021-06-17 12:49 ` Leon Romanovsky
2021-06-18 13:57 ` Haakon Bugge
2021-06-21 14:35 ` Jason Gunthorpe
2021-06-21 15:30 ` Haakon Bugge
2021-06-21 15:32 ` Jason Gunthorpe [this message]
2021-06-21 15:37 ` Haakon Bugge
2021-06-21 23:29 ` Jason Gunthorpe
2021-06-22 7:34 ` Haakon Bugge
2021-06-22 7:44 ` Haakon Bugge
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=20210621153255.GR1002214@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=haakon.bugge@oracle.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