From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754625AbdIROZy (ORCPT ); Mon, 18 Sep 2017 10:25:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37243 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752934AbdIROZx (ORCPT ); Mon, 18 Sep 2017 10:25:53 -0400 Date: Mon, 18 Sep 2017 07:25:48 -0700 From: "Paul E. McKenney" To: Boqun Feng Cc: j.alglave@ucl.ac.uk, luc.maranget@inria.fr, parri.andrea@gmail.com, stern@rowland.harvard.edu, dhowells@redhat.com, peterz@infradead.org, will.deacon@arm.com, npiggin@gmail.com, linux-kernel@vger.kernel.org Subject: Re: Memory-ordering recipes Reply-To: paulmck@linux.vnet.ibm.com References: <20170917230509.GA21394@linux.vnet.ibm.com> <20170918015353.GA15440@tardis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170918015353.GA15440@tardis> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17091814-0024-0000-0000-000002D3F1A9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007756; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000229; SDB=6.00918823; UDB=6.00461585; IPR=6.00699050; BA=6.00005594; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017195; XFM=3.00000015; UTC=2017-09-18 14:25:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091814-0025-0000-0000-000045768DAB Message-Id: <20170918142548.GI3521@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-18_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709180208 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 18, 2017 at 03:52:42PM +0800, Boqun Feng wrote: > On Sun, Sep 17, 2017 at 04:05:09PM -0700, Paul E. McKenney wrote: > > Hello! > > > > Hi Paul, > > > The topic of memory-ordering recipes came up at the Linux Plumbers > > Conference microconference on Friday, so I thought that I should summarize > > what is currently "out there": > > > > 1. memory-barriers.txt: A bit rambling and diffuse for a recipes > > document. > > > > 2. https://www.kernel.org/pub/linux/kernel/people/paulmck/LWNLinuxMM/Examples.html > > Many of the examples are on-point, but this is aimed more > > at understanding the memory model than at an organized set > > of recipes. > > > > 3. https://www.kernel.org/pub/linux/kernel/people/paulmck/LWNLinuxMM/Examples.html > > Duplicate links ;-) This should a link to some slides? Indeed! How about this one? http://www.linuxplumbersconf.org/2017/ocw//system/presentations/4708/original/LKMM-overview.2017.09.15b.pdf > > Slides 15-20. Again, some of the litmus tests are on-point, > > but the focus is more on understanding the memory model than on > > an organized set of recipes. > > > > So what litmus tests are needed? Here is my initial set: > > > > 1. Release-acquire chains, AKA ISA2, Z6.2, LB, and 3.LB > > > > Lots of variety here, can in some cases substitute: > > > > a. READ_ONCE() for smp_load_acquire() > > b. WRITE_ONCE() for smp_store_release() > > c. Dependencies for both smp_load_acquire() and > > smp_store_release(). > > d. smp_wmb() for smp_store_release() in first thread > > of ISA2 and Z6.2. > > e. smp_rmb() for smp_load_acquire() in last thread of ISA2. > > > > 2. MP (see test6.pdf for nickname translation) > > > > a. smp_store_release() / smp_load_acquire() > > b. rcu_assign_pointer() / rcu_dereference() > > c. smp_wmb() / smp_rmb() > > d. Replacing either of the above with smp_mb() > > > > 3. SB > > > > a. smp_mb(), as in lockless wait-wakeup coordination. > > And as in sys_membarrier()-scheduler coordination, > > for that matter. > > b. replace smp_mb() with smp_mb__before_atomic() followed > by a _relaxed cmpchg? As in pv_kick_node(): > > https://marc.info/?l=linux-kernel&m=150274124711012 > > Besides, do we also want to add Co* into the set? I think there may be > some people still confused to think per-loc SC is not held, and they may > add unnecessary barriers in their code. Those (Co*) recipes could serve > as a guide for state-machine style programming. Thoughts? Indeed, it would be good to have some single-variable-SC recipes. And single-variable-SC holds only if you use READ_ONCE(). ;-) Thanx, Paul