[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1343417168.32120.38.camel@twins>
Date: Fri, 27 Jul 2012 21:26:08 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Michel Lespinasse <walken@...gle.com>
Cc: riel@...hat.com, daniel.santos@...ox.com, aarcange@...hat.com,
dwmw2@...radead.org, akpm@...ux-foundation.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/6] rbtree: faster augmented insert
On Fri, 2012-07-20 at 05:31 -0700, Michel Lespinasse wrote:
> --- a/lib/rbtree.c
> +++ b/lib/rbtree.c
> @@ -88,7 +88,8 @@ __rb_rotate_set_parents(struct rb_node *old, struct rb_node *new,
> root->rb_node = new;
> }
>
> -void rb_insert_color(struct rb_node *node, struct rb_root *root)
> +inline void rb_insert_augmented(struct rb_node *node, struct rb_root *root,
> + rb_augment_rotate *augment)
Daniel probably knows best, but I would have expected something like:
__always_inline void
__rb_insert(struct rb_node *node, struct rb_root *root,
const rb_augment_rotate *augment)
Where you force inline and use a const function pointer since GCC is
better with inlining them -- iirc, Daniel?
> {
> struct rb_node *parent = rb_red_parent(node), *gparent, *tmp;
>
> @@ -152,6 +153,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
> rb_set_parent_color(tmp, parent,
> RB_BLACK);
> rb_set_parent_color(parent, node, RB_RED);
> + augment(parent, node);
And possibly:
if (augment)
augment(parent, node);
> parent = node;
> tmp = node->rb_right;
> }
> +static inline void dummy(struct rb_node *old, struct rb_node *new) {}
That would obviate the need for the dummy..
> +void rb_insert_color(struct rb_node *node, struct rb_root *root) {
placed your { wrong..
> + rb_insert_augmented(node, root, dummy);
> +}
> EXPORT_SYMBOL(rb_insert_color);
And use Daniel's __flatten here, like:
void rb_insert_color(struct rb_node *node, struct rb_root *root)
__flatten
{
__rb_insert(node, root, NULL);
}
EXPORT_SYMBOL(rb_insert_color);
void rb_insert_augmented(struct rb_node *node, struct rb_root *root,
const rb_augment_rotate *augment) __flatten
{
__rb_insert(node, root, augment);
}
EXPORT_SYMBOL(rb_insert_augmented);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists