Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbdHAJBe (ORCPT ); Tue, 1 Aug 2017 05:01:34 -0400 Received: from merlin.infradead.org ([205.233.59.134]:55760 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbdHAJBc (ORCPT ); Tue, 1 Aug 2017 05:01:32 -0400 Date: Tue, 1 Aug 2017 11:01:21 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: Boqun Feng , Will Deacon , linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , Randy Dunlap Subject: Re: [RFC][PATCH v3]: documentation,atomic: Add new documents Message-ID: <20170801090121.edo7mekhw3sann4h@hirez.programming.kicks-ass.net> References: <20170609092450.jwmldgtli57ozxgq@hirez.programming.kicks-ass.net> <20170609154442.GB9236@arm.com> <20170609193604.ncw3hhgvewzc3h5u@hirez.programming.kicks-ass.net> <20170611135632.sl72klbeklelupej@tardis> <20170612144929.3wiwtbqopsfpm3qk@hirez.programming.kicks-ass.net> <20170726115328.2sxiitivlnlq64dk@hirez.programming.kicks-ass.net> <20170726124750.vktrn5zi2gmpzfru@tardis> <20170731090535.rjgnoewqg7mhzr55@hirez.programming.kicks-ass.net> <20170731110403.ou3zqsp3uviqorkz@tardis> <20170731174345.GL3730@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170731174345.GL3730@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 865 Lines: 29 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.