From: Mathieu Desnoyers Date: Thu, 2 Jun 2011 15:04:09 +0000 (-0400) Subject: rbtree: test range lookups with larger ranges X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=20a104c3753dadd9418c9b58227743f9dab58fb7;p=urcu.git rbtree: test range lookups with larger ranges Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_urcu_rbtree.c b/tests/test_urcu_rbtree.c index 89e1c90..97f50e0 100644 --- a/tests/test_urcu_rbtree.c +++ b/tests/test_urcu_rbtree.c @@ -248,7 +248,7 @@ void *thr_reader(void *_count) cmm_smp_mb(); for (;;) { - /* search */ + /* search bottom of range */ for (i = 0; i < global_items; i++) { rcu_read_lock(); node = rcu_rbtree_search(&rbtree, @@ -258,13 +258,23 @@ void *thr_reader(void *_count) rcu_read_unlock(); } - /* search range */ + /* search end of range */ + for (i = 0; i < global_items; i++) { + rcu_read_lock(); + node = rcu_rbtree_search(&rbtree, + rcu_dereference(rbtree.root), + (void*) ((unsigned long) global_key[i] + 3)); + assert(!rcu_rbtree_is_nil(&rbtree, node)); + rcu_read_unlock(); + } + + /* search range (middle) */ for (i = 0; i < global_items; i++) { rcu_read_lock(); node = rcu_rbtree_search_range(&rbtree, rcu_dereference(rbtree.root), - global_key[i], - (void*) ((unsigned long) global_key[i] + 1)); + (void*) ((unsigned long) global_key[i] + 1), + (void*) ((unsigned long) global_key[i] + 2)); assert(!rcu_rbtree_is_nil(&rbtree, node)); rcu_read_unlock(); } @@ -358,11 +368,13 @@ void *thr_writer(void *_count) for (i = 0; i < NR_RAND; i++) { node = rbtree_alloc(); - key[i] = (void *)(unsigned long)(rand() % 2048); + //key[i] = (void *)(unsigned long)(rand() % 2048); + key[i] = (void *)(unsigned long)((rand() * 4) % 2048); //For more collisions //key[i] = (void *)(unsigned long)(rand() % 6); node->begin = key[i]; - node->end = (void *)((unsigned long) key[i] + 1); + //node->end = (void *)((unsigned long) key[i] + 4); + node->end = (void *)((unsigned long) key[i] + 4); rcu_read_lock(); rcu_rbtree_insert(&rbtree, node); rcu_read_unlock(); @@ -551,11 +563,13 @@ int main(int argc, char **argv) /* Insert items looked up by readers */ for (i = 0; i < global_items; i++) { node = rbtree_alloc(); - global_key[i] = (void *)(unsigned long)(rand() % 2048); + global_key[i] = (void *)(unsigned long)((rand() * 4) % 2048); + //global_key[i] = (void *)(unsigned long)(rand() % 2048); //For more collisions global_key[i] = (void *)(unsigned long)(rand() % 6); node->begin = global_key[i]; - node->end = (void *)((unsigned long) global_key[i] + 1); + //node->end = (void *)((unsigned long) global_key[i] + 1); + node->end = (void *)((unsigned long) global_key[i] + 4); rcu_rbtree_insert(&rbtree, node); } rcu_read_unlock();