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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to