From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbdIQXFR (ORCPT ); Sun, 17 Sep 2017 19:05:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49550 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751242AbdIQXFQ (ORCPT ); Sun, 17 Sep 2017 19:05:16 -0400 Date: Sun, 17 Sep 2017 16:05:09 -0700 From: "Paul E. McKenney" To: 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, boqun.feng@gmail.com, npiggin@gmail.com Cc: linux-kernel@vger.kernel.org Subject: Memory-ordering recipes Reply-To: paulmck@linux.vnet.ibm.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17091723-0036-0000-0000-0000026BD20D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007754; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000229; SDB=6.00918516; UDB=6.00461402; IPR=6.00698743; BA=6.00005593; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017189; XFM=3.00000015; UTC=2017-09-17 23:05:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091723-0037-0000-0000-000041CCEE50 Message-Id: <20170917230509.GA21394@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-17_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709170337 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! 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 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. Others? Thanx, Paul