rcuja: Use urcu_get_thread_id()
[userspace-rcu.git] / tests / test_urcu_ja.c
index 5dd16618faa4cadd3db411b2998a85e148160121..05725275cffaa0781e8bf8636c206e833b7db6bd 100644 (file)
@@ -433,7 +433,7 @@ int test_8bit_key(void)
                return -1;
        }
 
-       ret = cds_ja_destroy(test_ja, free_node);
+       ret = cds_ja_destroy(test_ja);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -632,7 +632,7 @@ int test_16bit_key(void)
                return -1;
        }
 
-       ret = cds_ja_destroy(test_ja, free_node);
+       ret = cds_ja_destroy(test_ja);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -770,7 +770,7 @@ int test_sparse_key(unsigned int bits, int nr_dup)
                return -1;
        }
 
-       ret = cds_ja_destroy(test_ja, free_node);
+       ret = cds_ja_destroy(test_ja);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -850,8 +850,10 @@ void *test_ja_rw_thr_reader(void *_count)
        struct cds_ja_node *ja_node;
        uint64_t key;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "reader", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -892,8 +894,8 @@ void *test_ja_rw_thr_reader(void *_count)
        rcu_unregister_thread();
 
        *count = URCU_TLS(nr_reads);
-       printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
-                       "reader", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_end %s, tid %lu\n",
+                       "reader", urcu_get_thread_id());
        printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
                        pthread_self(), URCU_TLS(lookup_fail),
                        URCU_TLS(lookup_ok));
@@ -913,8 +915,10 @@ void *test_ja_rw_thr_writer(void *_count)
        uint64_t key;
        int ret;
 
-       printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
-                       "writer", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_begin %s, tid %lu\n",
+                       "writer", urcu_get_thread_id());
+
+       URCU_TLS(rand_lookup) = urcu_get_thread_id() ^ time(NULL);
 
        set_affinity();
 
@@ -996,8 +1000,8 @@ void *test_ja_rw_thr_writer(void *_count)
 
        rcu_unregister_thread();
 
-       printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
-                       "writer", pthread_self(), (unsigned long) gettid());
+       printf_verbose("thread_end %s, tid %lu\n",
+                       "writer", urcu_get_thread_id());
        printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
                        "nr_delnoent %lu\n", pthread_self(), URCU_TLS(nr_add),
                        URCU_TLS(nr_addexist), URCU_TLS(nr_del),
@@ -1033,6 +1037,9 @@ int do_mt_populate_ja(void)
                URCU_TLS(nr_add)++;
                URCU_TLS(nr_writes)++;
                rcu_read_unlock();
+               /* Hash table resize only occurs in call_rcu thread */
+               if (!(iter % 100))
+                       rcu_quiescent_state();
                if (ret) {
                        fprintf(stderr, "Error (%d) adding node %" PRIu64 "\n",
                                ret, key);
@@ -1122,7 +1129,7 @@ int do_mt_test(void)
                return -1;
        }
 
-       ret = cds_ja_destroy(test_ja, free_node);
+       ret = cds_ja_destroy(test_ja);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                goto end;
@@ -1287,8 +1294,8 @@ int main(int argc, char **argv)
                printf_verbose("Validating lookups.\n");
        if (leak_detection)
                printf_verbose("Memory leak dection activated.\n");
-       printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
-                       "main", pthread_self(), (unsigned long)gettid());
+       printf_verbose("thread %-6s, tid %lu\n",
+                       "main", urcu_get_thread_id());
 
        memset(&act, 0, sizeof(act));
        ret = sigemptyset(&act.sa_mask);
This page took 0.027449 seconds and 4 git commands to generate.