From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752327AbbCBIYC (ORCPT ); Mon, 2 Mar 2015 03:24:02 -0500 Received: from casper.infradead.org ([85.118.1.10]:47350 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750834AbbCBIX6 (ORCPT ); Mon, 2 Mar 2015 03:23:58 -0500 Date: Mon, 2 Mar 2015 09:23:45 +0100 From: Peter Zijlstra To: Michel Lespinasse Cc: mingo@kernel.org, rusty@rustcorp.com.au, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, andi@firstfloor.org, rostedt@goodmis.org, tglx@linutronix.de, Andrea Arcangeli , David Woodhouse , Rik van Riel , Josh Triplett Subject: Re: [RFC][PATCH 5/9] rbtree: Make lockless searches non-fatal Message-ID: <20150302082345.GA5029@twins.programming.kicks-ass.net> References: <20150228212447.381543289@infradead.org> <20150228213110.129097991@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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:11:23PM -0800, Michel Lespinasse wrote: > On Sat, Feb 28, 2015 at 1:24 PM, Peter Zijlstra wrote: > > It generates slightly worse code, probably because gcc stinks at > > volatile. But in pointer chasing heavy code a few instructions more > > should not matter. > > So, I was worried that this would penalize all rbtree users, for the > benefit of just the one you're adding later in this series. We have > several rbtrees where we care about performance a lot, such as the > ones used in the scheduler or for indexing vmas. > > That said, I checked with the compiler we are using here (gcc 4.7 > variant) and I didn't see any change in the generated code. So, no > issue here for me. > > If the object code really is different in your setup, please use the > lib/rbtree_test module to check the performance impact of the change. I can do that; I had similar results to what Ingo posted. I meant to go build a 4.9 or 5.0 compiler to see what current GCC makes of it, but I've not yet gotten around to doing so. My result were with 4.8.3 iirc. > > For 2) I have carefully audited the code and drawn every intermediate > > link state and not found a loop. > > As Mathieu remarked, we are never modifying the currently active tree, > so the interrupt case is not the reason for avoiding loops. Correct, for the proposed use we do no. I did however double (actually triple) check this property because I feel its a good property to have, no matter what you do to the tree, a (simple) lookup will be non-fatal. But yes, I'll clarify things. > I think your proposal will work well for the use case you have in mind > (looking up modules based on address). However, I was wondering how > you would compare your proposal against an alternative I hard Josh > Triplett formulate before, where there would be one unique rbtree but > rotations would allocate new nodes rather than modify the existing > ones. I think this would be workable as well; I'm just not sure > whether this would be more or less generally applicable than your > proposal. Copying Josh in case he wants to chime in. So I was not aware of that particular solution. It changes the rb-tree from using internal storage like we do now, to requiring external storage. I do have experience with making an RCU safe (in memory) B+tree, and there the allocations were absolutely killing performance.