From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756146AbbDIRRL (ORCPT ); Thu, 9 Apr 2015 13:17:11 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:37885 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753997AbbDIRRI (ORCPT ); Thu, 9 Apr 2015 13:17:08 -0400 MIME-Version: 1.0 In-Reply-To: References: <20150408164813.810874878@infradead.org> <20150408170044.130755544@infradead.org> <552633A3.5020502@cn.fujitsu.com> <20150409081420.GM5029@twins.programming.kicks-ass.net> <55263E69.3020305@cn.fujitsu.com> <20150409121336.GU5029@twins.programming.kicks-ass.net> <20150409165917.GQ21418@twins.programming.kicks-ass.net> Date: Thu, 9 Apr 2015 10:17:07 -0700 X-Google-Sender-Auth: L3kdNW1KdCw2l1Hi1lnh0PW-5GA Message-ID: Subject: Re: [PATCH v4 6/9] rbtree: Implement generic latch_tree From: Linus Torvalds To: Peter Zijlstra Cc: Lai Jiangshan , Ingo Molnar , Rusty Russell , Mathieu Desnoyers , Oleg Nesterov , Paul McKenney , Linux Kernel Mailing List , Andi Kleen , Steven Rostedt , Thomas Gleixner , Michel Lespinasse , Andrea Arcangeli , David Woodhouse , Rik van Riel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 9, 2015 at 10:12 AM, Linus Torvalds wrote: > > It's just unusual, which I think makes it slightly harder to read for > a *human* just because it breaks the normal pattern of those things. > But there's nothing technically wrong with it. You could have written it as static __always_inline struct latch_tree_node * __lt_from_rb(struct rb_node *node, int idx) { return (void *)(node-idx); } which is actually shorter, but even if that container_of() use looks a bit unusual, I think the container_of() shows more clearly what you actually want. Plus it would be more reliable if you ever end up adding any other fields to the struct latch_tree_node. So I wouldn't actually suggest using that "(node-idx)" format. I think it should result in the exact same code, though. Linus