Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbdFLJrY (ORCPT ); Mon, 12 Jun 2017 05:47:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:53398 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752012AbdFLJrX (ORCPT ); Mon, 12 Jun 2017 05:47:23 -0400 Date: Mon, 12 Jun 2017 11:47:20 +0200 From: Jan Kara To: Davidlohr Bueso Cc: Jan Kara , mingo@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, ldufour@linux.vnet.ibm.com, mhocko@suse.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH 1/8] rbtree: Cache leftmost node internally Message-ID: <20170612094720.GB22728@quack2.suse.cz> References: <20170608180329.11457-1-dave@stgolabs.net> <20170608180329.11457-2-dave@stgolabs.net> <20170609074347.GA15968@quack2.suse.cz> <20170609143250.GB20320@linux-80c1.suse> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170609143250.GB20320@linux-80c1.suse> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1256 Lines: 37 On Fri 09-06-17 07:32:50, Davidlohr Bueso wrote: > >>@@ -150,6 +161,7 @@ extern void __rb_erase_color(struct rb_node *parent, struct rb_root *root, > >> > >> static __always_inline struct rb_node * > >> __rb_erase_augmented(struct rb_node *node, struct rb_root *root, > >>+ struct rb_node **leftmost, > >> const struct rb_augment_callbacks *augment) > >> { > >> struct rb_node *child = node->rb_right; > >>@@ -157,6 +169,9 @@ __rb_erase_augmented(struct rb_node *node, struct rb_root *root, > >> struct rb_node *parent, *rebalance; > >> unsigned long pc; > >> > >>+ if (leftmost && node == *leftmost) > >>+ *leftmost = rb_next(node); > >>+ > >> if (!tmp) { > >> /* > >> * Case 1: node to erase has no more than 1 child (easy!) > > > >Why do you propagate e.g. 'leftmost' down to __rb_erase_augmented() when > >you could just handle everything within rb_erase_augmented_cached? > >Similarly for other functions like __rb_insert()... It would seem like less > >churn and I don't see downside to it... > > I propagate args so we don't have to duplicate the checks between the regular > and augmented rbtrees. OK, yeah. Feel free to add: Reviewed-by: Jan Kara Honza -- Jan Kara SUSE Labs, CR