lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 25 Jul 2012 12:10:31 -0400
From:	Rik van Riel <riel@...hat.com>
To:	Michel Lespinasse <walken@...gle.com>
CC:	peterz@...radead.org, 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 07/20/2012 08:31 AM, Michel Lespinasse wrote:

> +++ 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)
>   {
>   	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);

> +static inline void dummy(struct rb_node *old, struct rb_node *new) {}
> +
> +void rb_insert_color(struct rb_node *node, struct rb_root *root) {
> +	rb_insert_augmented(node, root, dummy);
> +}
>   EXPORT_SYMBOL(rb_insert_color);

While the above is what I would have done, the
question remains "what if the compiler decides
to not inline the function after all, and does
not remove the call to the dummy function in
rb_insert_color as a result?

Do we have some way to force inlining, so the
compiler is more likely to optimize out the
dummy call?

>   static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
> diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c
> index 2dfafe4..5ace332 100644
> --- a/lib/rbtree_test.c
> +++ b/lib/rbtree_test.c
> @@ -67,22 +67,37 @@ static void augment_callback(struct rb_node *rb, void *unused)
>   	node->augmented = augment_recompute(node);
>   }
>
> +static void augment_rotate(struct rb_node *rb_old, struct rb_node *rb_new)
> +{
> +	struct test_node *old = rb_entry(rb_old, struct test_node, rb);
> +	struct test_node *new = rb_entry(rb_new, struct test_node, rb);
> +
> +	/* Rotation doesn't change subtree's augmented value */
> +	new->augmented = old->augmented;
> +	old->augmented = augment_recompute(old);
> +}

Is it worth documenting that rb_old is always the
parent of rb_new (at least, it seems to be in this
patch) ?

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ