Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754539AbdGCVKt (ORCPT ); Mon, 3 Jul 2017 17:10:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48854 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752533AbdGCVKm (ORCPT ); Mon, 3 Jul 2017 17:10:42 -0400 Date: Mon, 3 Jul 2017 14:10:35 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Will Deacon , Linux Kernel Mailing List , NetFilter , Network Development , Oleg Nesterov , Andrew Morton , Ingo Molnar , Davidlohr Bueso , Manfred Spraul , Tejun Heo , Arnd Bergmann , "linux-arch@vger.kernel.org" , Peter Zijlstra , Alan Stern , Andrea Parri Subject: Re: [PATCH RFC 08/26] locking: Remove spin_unlock_wait() generic definitions Reply-To: paulmck@linux.vnet.ibm.com References: <20170629235918.GA6445@linux.vnet.ibm.com> <1498780894-8253-8-git-send-email-paulmck@linux.vnet.ibm.com> <20170630091928.GC9726@arm.com> <20170630123815.GT2393@linux.vnet.ibm.com> <20170630131339.GA14118@arm.com> <20170630221840.GI2393@linux.vnet.ibm.com> <20170703131514.GE1573@arm.com> <20170703161851.GY2393@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-GCONF: 00 x-cbid: 17070321-0048-0000-0000-000001B9DDC1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007315; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00882394; UDB=6.00440092; IPR=6.00662585; BA=6.00005450; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016061; XFM=3.00000015; UTC=2017-07-03 21:10:38 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070321-0049-0000-0000-000041C121B2 Message-Id: <20170703211035.GH2393@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-03_14:,, 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-1703280000 definitions=main-1707030345 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1248 Lines: 34 On Mon, Jul 03, 2017 at 09:40:22AM -0700, Linus Torvalds wrote: > On Mon, Jul 3, 2017 at 9:18 AM, Paul E. McKenney > wrote: > > > > Agreed, and my next step is to look at spin_lock() followed by > > spin_is_locked(), not necessarily the same lock. > > Hmm. Most (all?) "spin_is_locked()" really should be about the same > thread that took the lock (ie it's about asserts and lock debugging). Good to know, that does make things easier. ;-) I am not certain that it is feasible to automatically recognize non-assert/non-debugging use cases of spin_is_locked(), but there is aways manual inspection. > The optimistic ABBA avoidance pattern for spinlocks *should* be > > spin_lock(inner) > ... > if (!try_lock(outer)) { > spin_unlock(inner); > .. do them in the right order .. > > so I don't think spin_is_locked() should have any memory barriers. > > In fact, the core function for spin_is_locked() is arguably > arch_spin_value_unlocked() which doesn't even do the access itself. OK, so we should rework any cases where people are relying on acquisition of one spin_lock() being ordered with a later spin_is_locked() on some other lock by that same thread. Thanx, Paul