Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932557AbbDIIG0 (ORCPT ); Thu, 9 Apr 2015 04:06:26 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:7401 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932180AbbDIIGV (ORCPT ); Thu, 9 Apr 2015 04:06:21 -0400 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="90410575" Message-ID: <552633A3.5020502@cn.fujitsu.com> Date: Thu, 9 Apr 2015 16:09:07 +0800 From: Lai Jiangshan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Peter Zijlstra , , , , , , CC: , , , , Michel Lespinasse , Andrea Arcangeli , David Woodhouse , Rik van Riel Subject: Re: [PATCH v4 6/9] rbtree: Implement generic latch_tree References: <20150408164813.810874878@infradead.org> <20150408170044.130755544@infradead.org> In-Reply-To: <20150408170044.130755544@infradead.org> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.103] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1420 Lines: 35 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(), thus we can find the encapsulating latch_tree_nodes from rb_node or latch_tree_node. and struct latch_tree_ops uses latch_tree_nodes instead. Did I miss anything? If the @priv is possible to be removed, removing it will simplify this file but it may add a little more code in the module.c where the ltn_core<n_init can't share the same ->less() and ->comp() after. If you do remove @priv, please also use rb_node instead of old latch_tree_node and rename old latch_tree_nodes to latch_tree_node. -- 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/