From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbcJHOTi (ORCPT ); Sat, 8 Oct 2016 10:19:38 -0400 Received: from merlin.infradead.org ([205.233.59.134]:50404 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbcJHOT3 (ORCPT ); Sat, 8 Oct 2016 10:19:29 -0400 Date: Sat, 8 Oct 2016 16:01:36 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: Linus Torvalds , Waiman Long , Jason Low , Ding Tianhong , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Davidlohr Bueso , Tim Chen , Terry Rudd , "Paul E. McKenney" , Chris Wilson , Daniel Vetter , Rob Clark Subject: Re: [PATCH -v4 1/8] locking/drm: Kill mutex trickery Message-ID: <20161008140136.GG3142@twins.programming.kicks-ass.net> References: <20161007145243.361481786@infradead.org> <20161007150210.927453282@infradead.org> <20161007154351.GL3117@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 08, 2016 at 01:58:07PM +0200, Thomas Gleixner wrote: > Hmm. I'm not a great fan of this, because that requires an conditional > unlock mechanism. > > res = trylock_recursive(lock); > if (res == FAILED) > goto out; > ..... > > if (res == SUCCESS) > unlock(lock); > > While if you actually keep track of recursion you can do: > > if (!trylock_recursive(lock)) > goto out; > > .... > > unlock_recursive(lock); > > or even: > > lock_recursive(lock); > > unlock_recursive(lock); > > That's making lock/trylock and unlock symetric, so its obvious in the > source what's going on and the recursion tracking allows for better > debugability. Hurm,. so I thought that in general we disliked recursive locking because it quickly turns in to a horrible mess. Adding such primitives makes it 'easy' to use recursive locking and then where does it stop?