rcuja tests: add vs add unique
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 31 May 2013 16:42:40 +0000 (12:42 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 31 May 2013 16:42:40 +0000 (12:42 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/runja.sh
tests/test_urcu_ja.c

index 9f18969ef7297391a5353b5523d484fa1f5f4797..1be4224d133fea896094fc6be03856ea289e278f 100755 (executable)
@@ -18,7 +18,7 @@ EXTRA_PARAMS=-v
 # ** test update coherency with single-value table
 
 # sanity test
-${TESTPROG} 0 $((4*${THREAD_MUL})) ${TIME_UNITS} -s ${EXTRA_PARAMS} || exit 1
+${TESTPROG} 0 $((4*${THREAD_MUL})) ${TIME_UNITS} -t ${EXTRA_PARAMS} || exit 1
 
 # rw test, single key, add and del randomly, 4 threads
 # key range: init, lookup, and update: 0 to 0
index 85404845800ff8e47458b85728f5303cedda9fd8..a4e7d0efae69127f8cd00746020a91b1d694cb45 100644 (file)
@@ -74,6 +74,8 @@ unsigned int nr_writers;
 static unsigned int add_ratio = 50;
 static uint64_t key_mul = 1ULL;
 
+static int add_unique, add_replace;
+
 static pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 void set_affinity(void)
@@ -165,6 +167,8 @@ void show_usage(int argc, char **argv)
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-v] (verbose output)\n");
        printf("        [-a cpu#] [-a cpu#]... (affinity)\n");
+       printf("        [-u] Add unique keys.\n");
+       printf("        [-s] Replace existing keys.\n");
 printf("        [not -u nor -s] Add entries (supports redundant keys).\n");
        printf("        [-r ratio] Add ratio (in %% of add+removal).\n");
        printf("        [-k] Populate init nodes.\n");
@@ -175,7 +179,7 @@ printf("        [not -u nor -s] Add entries (supports redundant keys).\n");
        printf("        [-N size] Write pool size.\n");
        printf("        [-O size] Init pool size.\n");
        printf("        [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).\n");
-       printf("        [-s] Do sanity test.\n");
+       printf("        [-t] Do sanity test.\n");
        printf("        [-B] Key bits for multithread test (default: 32).\n");
        printf("        [-m factor] Key multiplication factor.\n");
        printf("\n\n");
@@ -673,14 +677,26 @@ void *test_ja_rw_thr_writer(void *_count)
                        key *= key_mul;
                        ja_test_node_init(node, key);
                        rcu_read_lock();
-                       ret_node = cds_ja_add_unique(test_ja, key, &node->node);
-                       rcu_read_unlock();
-                       if (ret_node != &node->node) {
-                               free(node);
-                               URCU_TLS(nr_addexist)++;
+                       if (add_unique) {
+                               ret_node = cds_ja_add_unique(test_ja, key, &node->node);
+                               if (ret_node != &node->node) {
+                                       free(node);
+                                       URCU_TLS(nr_addexist)++;
+                               } else {
+                                       URCU_TLS(nr_add)++;
+                               }
+                       } else if (add_replace) {
+                               assert(0);      /* not implemented yet. */
                        } else {
-                               URCU_TLS(nr_add)++;
+                               ret = cds_ja_add(test_ja, key, &node->node);
+                               if (ret) {
+                                       fprintf(stderr, "Error in cds_ja_add: %d\n", ret);
+                                       free(node);
+                               } else {
+                                       URCU_TLS(nr_add)++;
+                               }
                        }
+                       rcu_read_unlock();
                } else {
                        struct ja_test_node *node;
 
@@ -949,7 +965,7 @@ int main(int argc, char **argv)
                case 'V':
                        validate_lookup = 1;
                        break;
-               case 's':
+               case 't':
                        sanity_test = 1;
                        break;
                case 'B':
@@ -958,6 +974,12 @@ int main(int argc, char **argv)
                case 'm':
                        key_mul = atoll(argv[++i]);
                        break;
+               case 'u':
+                       add_unique = 1;
+                       break;
+               case 's':
+                       add_replace = 1;
+                       break;
                }
        }
 
@@ -966,6 +988,9 @@ int main(int argc, char **argv)
        printf_verbose("Writer delay : %lu loops.\n", wdelay);
        printf_verbose("Reader duration : %lu loops.\n", rduration);
        printf_verbose("Add ratio: %u%%.\n", add_ratio);
+       printf_verbose("Mode:%s%s.\n",
+               " add/remove",
+               add_unique ? " uniquify" : ( add_replace ? " replace" : " insert"));
        printf_verbose("Key multiplication factor: %" PRIu64 ".\n", key_mul);
        printf_verbose("Init pool size offset %lu size %lu.\n",
                init_pool_offset, init_pool_size);
This page took 0.027781 seconds and 4 git commands to generate.