From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753146AbdJKOwX (ORCPT ); Wed, 11 Oct 2017 10:52:23 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55690 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbdJKOwW (ORCPT ); Wed, 11 Oct 2017 10:52:22 -0400 Date: Wed, 11 Oct 2017 07:50:00 -0700 From: "Paul E. McKenney" To: Will Deacon Cc: David Howells , linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, mark.rutland@arm.com, linux-arch@vger.kernel.org, peterz@infradead.org, Jonathan Corbet , Alexander Kuleshov Subject: Re: [PATCH RFC tip/core/rcu 12/15] lib/assoc_array: Remove smp_read_barrier_depends() Reply-To: paulmck@linux.vnet.ibm.com References: <20171010155042.GD3521@linux.vnet.ibm.com> <1507594969-8347-12-git-send-email-paulmck@linux.vnet.ibm.com> <20171010001951.GA6476@linux.vnet.ibm.com> <8079.1507628146@warthog.procyon.org.uk> <26455.1507724399@warthog.procyon.org.uk> <20171011122217.GD11106@arm.com> <20171011125451.GW3521@linux.vnet.ibm.com> <20171011141817.GG11106@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171011141817.GG11106@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17101114-2213-0000-0000-0000022A0CA6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007878; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000236; SDB=6.00929626; UDB=6.00467903; IPR=6.00709897; BA=6.00005634; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017491; XFM=3.00000015; UTC=2017-10-11 14:50:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101114-2214-0000-0000-000057D211A4 Message-Id: <20171011145000.GA3521@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-11_05:,, 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-1710110206 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 11, 2017 at 03:18:17PM +0100, Will Deacon wrote: > On Wed, Oct 11, 2017 at 05:54:51AM -0700, Paul E. McKenney wrote: > > On Wed, Oct 11, 2017 at 01:22:17PM +0100, Will Deacon wrote: > > > On Wed, Oct 11, 2017 at 01:19:59PM +0100, David Howells wrote: > > > > Paul E. McKenney wrote: > > > > > > > > > - node = result.terminal_node.node; > > > > > - smp_read_barrier_depends(); > > > > > + node = READ_ONCE(result.terminal_node.node); /* Address dependency. */ > > > > > > > > The main problem I have with this method of annotation is that it's not > > > > obvious there's a barrier there or which side the barrier is. > > > > > > > > I think one of the trickiest issues is that a barrier is typically between two > > > > things and we're not making it clear what those two things actually are. > > > > > > > > Also, I would say that the most natural interpretation of READ_ONCE() is that > > > > the implicit barrier comes after the read, e.g.: > > > > > > > > f = READ_ONCE(stuff->foo); > > > > /* Implied barrier */ > > > > look_at(f->a); > > > > look_at(f->b); > > > > > > > > I.e. READ_ONCE() prevents stuff->foo from being reread whilst you access f and > > > > orders LOAD(stuff->foo) before LOAD(f->a) and LOAD(f->b). > > > > > > FWIW, that's exactly what my patches do, this fixup looks a bit weird > > > because it removes a prior barrier which suggests that either (a) it's in > > > the wrong place to start with, or (b) we're annotating the wrong load. > > > > You lost me on this one. Here is the side-by-side change, minus the > > comment: > > > > node = result.terminal_node.node; node = READ_ONCE(result.terminal_node.node); > > smp_read_barrier_depends(); > > > > The barrier was after the load that got annotated. > > Yes, sorry, I completely lost my ability to read diff. Looking again, I > don't actually know what's being ordered by the smp_read_barrier_depends() > in the snippet above, given that assigning "node" is a load from the stack > afaict. Good point, and in fact the required READ_ONCE() already exists off in assoc_array_walk(). Updated. Thanx, Paul