From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753865AbbCBI1x (ORCPT ); Mon, 2 Mar 2015 03:27:53 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:43257 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753835AbbCBI1s (ORCPT ); Mon, 2 Mar 2015 03:27:48 -0500 Date: Mon, 2 Mar 2015 09:27:26 +0100 From: Peter Zijlstra To: Mathieu Desnoyers Cc: mingo@kernel.org, rusty@rustcorp.com.au, oleg@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, Michel Lespinasse , Andrea Arcangeli , David Woodhouse , Rik van Riel Subject: Re: [RFC][PATCH 5/9] rbtree: Make lockless searches non-fatal Message-ID: <20150302082726.GB5029@twins.programming.kicks-ass.net> References: <20150228212447.381543289@infradead.org> <20150228213110.129097991@infradead.org> <249901737.193802.1425217929395.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <249901737.193802.1425217929395.JavaMail.zimbra@efficios.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 01, 2015 at 01:52:09PM +0000, Mathieu Desnoyers wrote: > > 2) there must not be (temporary) loops in the tree structure in the > > modifier's program order, this would cause a lookup which > > interrupts the modifier to get stuck indefinitely. > > For (2), I don't think this is how the situation should be described. > > Let's consider a scenario where an interrupt nests over the modification. > First, the modification will switch the latch to the other version of the > tree. Therefore, the interrupt will see a fully consistent tree, not the > tree being modified. Therefore, a temporary loop in the tree should not > be an issue for that peculiar situation. > > However, if we have another thread traversing the tree while we > concurrently switch the latch and modify one version of the tree, > creating a temporary loop in the tree, this thread could possibly: > > A) deadlock with the modification if there is a locking dependency > between tree modification, tree read, and another lock (transitive > dependency). > B) have the modifier starved by the other thread, if that thread has > a higher scheduling priority (e.g. RT) than the modifier. The high > priority thread would then use all its CPU time to perform the > temporary loop. > > So I agree that loops are unwanted there: it allows us to never have > to care about situations A and B. However, the explanation about why > should not involve, AFAIU, an interrupt handler nesting over the tree > modification, because this is precisely one scenario that should not > care about loops. > > Thoughs ? This is true for the (later) proposed latched RB-tree, the description is however true in general. If you somehow did a lookup while doing the modification and you have loops in program order, you're stuck. So in the interest of robustness I think we want this property nonetheless. And its 'free', I didn't have to change any code for this. I shall however clarify this point in the latched RB-tree patch.