[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170801101900.GB8702@arm.com>
Date: Tue, 1 Aug 2017 11:19:00 +0100
From: Will Deacon <will.deacon@....com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Boqun Feng <boqun.feng@...il.com>,
linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [RFC][PATCH v3]: documentation,atomic: Add new documents
On Tue, Aug 01, 2017 at 11:01:21AM +0200, Peter Zijlstra wrote:
> On Mon, Jul 31, 2017 at 10:43:45AM -0700, Paul E. McKenney wrote:
>
> > Why wouldn't the following have ACQUIRE semantics?
> >
> > atomic_inc(&var);
> > smp_mb__after_atomic();
> >
> > Is the issue that there is no actual value returned or some such?
>
> Yes, so that the inc is a load-store, and thus there is a load, we loose
> the value.
>
> But I see your point I think. Irrespective of still having the value,
> the ordering is preserved and nothing should pass across that.
>
> > So if I have something like this, the assertion really can trigger?
> >
> > WRITE_ONCE(x, 1); atomic_inc(&y);
> > r0 = xchg_release(&y, 5); smp_mb__after_atomic();
> > r1 = READ_ONCE(x);
> >
> >
> > WARN_ON(r0 == 0 && r1 == 0);
> >
> > I must confess that I am not seeing why we would want to allow this
> > outcome.
>
> No you are indeed quite right. I just wasn't creative enough. Thanks for
> the inspiration.
Just to close this out, we agree that an smp_rmb() instead of
smp_mb__after_atomic() would *not* forbid this outcome, right?
Will
Powered by blists - more mailing lists