From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Stern Subject: Re: [PATCH] tools/memory-model: document the "one-time init" pattern Date: Fri, 17 Jul 2020 13:51:38 -0400 Message-ID: <20200717175138.GB1156312@rowland.harvard.edu> References: <20200717044427.68747-1-ebiggers@kernel.org> <20200717174750.GQ12769@casper.infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from netrider.rowland.org ([192.131.102.5]:33613 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727121AbgGQRvj (ORCPT ); Fri, 17 Jul 2020 13:51:39 -0400 Content-Disposition: inline In-Reply-To: <20200717174750.GQ12769@casper.infradead.org> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Matthew Wilcox Cc: Eric Biggers , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, "Paul E . McKenney" , linux-fsdevel@vger.kernel.org, Akira Yokosawa , Andrea Parri , Boqun Feng , Daniel Lustig , "Darrick J . Wong" , Dave Chinner , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon On Fri, Jul 17, 2020 at 06:47:50PM +0100, Matthew Wilcox wrote: > On Thu, Jul 16, 2020 at 09:44:27PM -0700, Eric Biggers wrote: ... > > + /* on success, pairs with smp_load_acquire() above and below */ > > + if (cmpxchg_release(&foo, NULL, p) != NULL) { > > Why do we have cmpxchg_release() anyway? Under what circumstances is > cmpxchg() useful _without_ having release semantics? To answer just the last question: cmpxchg() is useful for lock acquisition, in which case it needs to have acquire semantics rather than release semantics. Alan Stern