Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbbDIIOl (ORCPT ); Thu, 9 Apr 2015 04:14:41 -0400 Received: from casper.infradead.org ([85.118.1.10]:52859 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbbDIIOh (ORCPT ); Thu, 9 Apr 2015 04:14:37 -0400 Date: Thu, 9 Apr 2015 10:14:20 +0200 From: Peter Zijlstra To: Lai Jiangshan Cc: mingo@kernel.org, rusty@rustcorp.com.au, mathieu.desnoyers@efficios.com, oleg@redhat.com, paulmck@linux.vnet.ibm.com, torvalds@linux-foundation.org, 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: [PATCH v4 6/9] rbtree: Implement generic latch_tree Message-ID: <20150409081420.GM5029@twins.programming.kicks-ass.net> References: <20150408164813.810874878@infradead.org> <20150408170044.130755544@infradead.org> <552633A3.5020502@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <552633A3.5020502@cn.fujitsu.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 Content-Length: 1178 Lines: 31 On Thu, Apr 09, 2015 at 04:09:07PM +0800, Lai Jiangshan wrote: > On 04/09/2015 12:48 AM, Peter Zijlstra wrote: > > > + > > +struct latch_tree_node { > > + /* > > + * Because we have an array of two entries in struct latch_tree_nodes > > + * it's not possible to use container_of() to get back to the > > + * encapsulating structure; therefore we have to put in a back pointer. > > + */ > > + void *priv; > > + struct rb_node node; > > +}; > > I don't think @priv is strictly needed. It is possible to use container_of() > to go back. @priv is even not used in this file (except the initialization). > > First, we can use container_of() to find encapsulating structure from the > struct latch_tree_nodeS. > > Second, we can add a @idx to __lt_insert() and __lt_find(), insert yes, find no. Remember that both nodes are in the _same_ tree. There is no way of knowing if a tree node is an init or core node while iterating. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/