From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932481AbbDMSnD (ORCPT ); Mon, 13 Apr 2015 14:43:03 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:35167 "EHLO e31.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751177AbbDMSnB (ORCPT ); Mon, 13 Apr 2015 14:43:01 -0400 Date: Mon, 13 Apr 2015 11:42:53 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Mathieu Desnoyers , Ingo Molnar , Peter Zijlstra , Rusty Russell , Oleg Nesterov , Linux Kernel Mailing List , Andi Kleen , Steven Rostedt , Thomas Gleixner , Lai Jiangshan , George Spelvin , Andrea Arcangeli , David Woodhouse , Rik van Riel , Michel Lespinasse Subject: Re: [PATCH v5 05/10] seqlock: Better document raw_write_seqcount_latch() Message-ID: <20150413184253.GZ23685@linux.vnet.ibm.com> Reply-To: paulmck@linux.vnet.ibm.com References: <20150413141126.756350256@infradead.org> <20150413141213.492831596@infradead.org> <20150413163201.GC6040@gmail.com> <1979415164.29724.1428944899771.JavaMail.zimbra@efficios.com> <20150413174323.GY23685@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15041318-8236-0000-0000-00000ABACF18 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 13, 2015 at 11:21:46AM -0700, Linus Torvalds wrote: > On Mon, Apr 13, 2015 at 10:43 AM, Paul E. McKenney > wrote: > > > > A shorthand for READ_ONCE + smp_read_barrier_depends() is the shiny > > new lockless_dereference() > > Related side note - I think people should get used to seeing > "smp_load_acquire()". It has well-defined memory ordering properties > and should generally perform well on most architectures. It's (much) > stronger than lockless_dereference(), and together with > smp_store_release() you can make rather clear guarantees about passing > data locklessly from one CPU to another. > > I'd like to see us use more of the pattern of > > - one thread does: > > .. allocate/create some data > smp_store_release() to "expose it" > > - another thread does: > > smp_load_acquire() to read index/pointer/flag/whatever > .. use the data any damn way you want .. > > and we should probably aim to prefer that pattern over a lot of our > traditional memory barriers. I couldn't agree more! RCU made a similar move from open-coding smp_read_barrier_depends() to using rcu_dereference() many years ago, and that change made RCU code -much- easier to read and understand. I believe that moving from smp_mb(), smp_rmb(), and smp_wmb() to smp_store_release() and smp_load_acquire() will provide similar maintainability benefits. Furthermore, when the current code uses smp_mb(), smp_store_release() and smp_load_acquire() generate faster code on most architectures. Thanx, Paul