lkml.org 
[lkml]   [2018]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V2 11/19] csky: Atomic operations
On Sat, Jul 07, 2018 at 10:10:24PM +0200, Andrea Parri wrote:
> On Sat, Jul 07, 2018 at 04:08:47PM +0800, Guo Ren wrote:
> > On Fri, Jul 06, 2018 at 02:17:16PM +0200, Peter Zijlstra wrote:
>
> > CPU0 CPU1
> >
> > WRITE_ONCE(x, 1) WRITE_ONCE(y, 1)
> > r0 = xchg(&y, 2) r1 = xchg(&x, 2)
> >
> > must not allow: r0==0 && r1==0
> > So we must add a smp_mb between WRITE_ONCE() and xchg(), right?
>
> The state (r0==0 && r1==0) _must_ not be allowed in the above snippet (so,
> even without the additional smp_mb() between WRITE_ONCE() and xchg()). In
> informal terms, xchg() provides the smp_mb().
Got it, thx.

> Compare implementations of xchg() and xchg_relaxed(). The following could
> also be helpful (in addition to the references pointed out earlier):
>
> Documentation/atomic_t.txt
Thx for the tip.

Guo Ren

\
 
 \ /
  Last update: 2018-07-08 03:06    [W:0.090 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site