4 * Userspace RCU library - test program
6 * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "test_urcu_ja.h"
28 DEFINE_URCU_TLS(unsigned int, rand_lookup
);
29 DEFINE_URCU_TLS(unsigned long, nr_add
);
30 DEFINE_URCU_TLS(unsigned long, nr_addexist
);
31 DEFINE_URCU_TLS(unsigned long, nr_del
);
32 DEFINE_URCU_TLS(unsigned long, nr_delnoent
);
33 DEFINE_URCU_TLS(unsigned long, lookup_fail
);
34 DEFINE_URCU_TLS(unsigned long, lookup_ok
);
36 struct cds_ja
*test_ja
;
38 volatile int test_go
, test_stop
;
42 unsigned long duration
;
44 /* read-side C.S. duration, in loops */
45 unsigned long rduration
;
47 unsigned long init_populate
;
50 unsigned long init_pool_offset
, lookup_pool_offset
, write_pool_offset
;
51 unsigned long init_pool_size
= DEFAULT_RAND_POOL
,
52 lookup_pool_size
= DEFAULT_RAND_POOL
,
53 write_pool_size
= DEFAULT_RAND_POOL
;
56 unsigned int key_bits
= 32;
62 unsigned int cpu_affinities
[NR_CPUS
];
63 unsigned int next_aff
= 0;
66 pthread_mutex_t affinity_mutex
= PTHREAD_MUTEX_INITIALIZER
;
68 DEFINE_URCU_TLS(unsigned long long, nr_writes
);
69 DEFINE_URCU_TLS(unsigned long long, nr_reads
);
71 unsigned int nr_readers
;
72 unsigned int nr_writers
;
74 static unsigned int add_ratio
= 50;
75 static uint64_t key_mul
= 1ULL;
77 static int add_unique
, add_replace
;
79 static pthread_mutex_t rcu_copy_mutex
= PTHREAD_MUTEX_INITIALIZER
;
81 static int leak_detection
;
82 static unsigned long test_nodes_allocated
, test_nodes_freed
;
84 void set_affinity(void)
93 #if HAVE_SCHED_SETAFFINITY
94 ret
= pthread_mutex_lock(&affinity_mutex
);
96 perror("Error in pthread mutex lock");
99 cpu
= cpu_affinities
[next_aff
++];
100 ret
= pthread_mutex_unlock(&affinity_mutex
);
102 perror("Error in pthread mutex unlock");
107 #if SCHED_SETAFFINITY_ARGS == 2
108 sched_setaffinity(0, &mask
);
110 sched_setaffinity(0, sizeof(mask
), &mask
);
112 #endif /* HAVE_SCHED_SETAFFINITY */
115 void rcu_copy_mutex_lock(void)
118 ret
= pthread_mutex_lock(&rcu_copy_mutex
);
120 perror("Error in pthread mutex lock");
125 void rcu_copy_mutex_unlock(void)
129 ret
= pthread_mutex_unlock(&rcu_copy_mutex
);
131 perror("Error in pthread mutex unlock");
137 struct ja_test_node
*node_alloc(void)
139 struct ja_test_node
*node
;
141 node
= calloc(sizeof(*node
), 1);
142 if (leak_detection
&& node
)
143 uatomic_inc(&test_nodes_allocated
);
148 void free_node(struct ja_test_node
*node
)
152 uatomic_inc(&test_nodes_freed
);
156 void free_node_cb(struct rcu_head
*head
)
158 struct ja_test_node
*node
=
159 caa_container_of(head
, struct ja_test_node
, node
.head
);
165 void test_delete_all_nodes(struct cds_lfht
*ht
)
167 struct cds_lfht_iter iter
;
168 struct lfht_test_node
*node
;
169 unsigned long count
= 0;
171 cds_lfht_for_each_entry(ht
, &iter
, node
, node
) {
174 ret
= cds_lfht_del(test_ht
, cds_lfht_iter_get_node(&iter
));
176 call_rcu(&node
->head
, free_node_cb
);
179 printf("deleted %lu nodes.\n", count
);
183 void show_usage(int argc
, char **argv
)
185 printf("Usage : %s nr_readers nr_writers duration (s)\n", argv
[0]);
187 printf(" [-r] [-w] (yield reader and/or writer)\n");
189 printf(" [-d delay] (writer period (us))\n");
190 printf(" [-c duration] (reader C.S. duration (in loops))\n");
191 printf(" [-v] (verbose output)\n");
192 printf(" [-a cpu#] [-a cpu#]... (affinity)\n");
193 printf(" [-u] Add unique keys.\n");
194 printf(" [-s] Replace existing keys.\n");
195 printf(" [not -u nor -s] Add entries (supports redundant keys).\n");
196 printf(" [-r ratio] Add ratio (in %% of add+removal).\n");
197 printf(" [-k] Populate init nodes.\n");
198 printf(" [-R offset] Lookup pool offset.\n");
199 printf(" [-S offset] Write pool offset.\n");
200 printf(" [-T offset] Init pool offset.\n");
201 printf(" [-M size] Lookup pool size.\n");
202 printf(" [-N size] Write pool size.\n");
203 printf(" [-O size] Init pool size.\n");
204 printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).\n");
205 printf(" [-t] Do sanity test.\n");
206 printf(" [-B] Key bits for multithread test (default: 32).\n");
207 printf(" [-m factor] Key multiplication factor.\n");
208 printf(" [-l] Memory leak detection.\n");
214 int test_8bit_key(void)
219 /* Test with 8-bit key */
220 test_ja
= cds_ja_new(8);
222 printf("Error allocating judy array.\n");
227 printf("Test #1: add keys (8-bit).\n");
228 for (key
= 0; key
< 200; key
++) {
229 struct ja_test_node
*node
= node_alloc();
231 ja_test_node_init(node
, key
);
233 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
236 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
243 printf("Test #2: successful key lookup (8-bit).\n");
244 for (key
= 0; key
< 200; key
++) {
245 struct cds_hlist_head head
;
248 head
= cds_ja_lookup(test_ja
, key
);
249 if (cds_hlist_empty(&head
)) {
250 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
256 printf("Test #3: unsuccessful key lookup (8-bit).\n");
257 for (key
= 200; key
< 240; key
++) {
258 struct cds_hlist_head head
;
261 head
= cds_ja_lookup(test_ja
, key
);
262 if (!cds_hlist_empty(&head
)) {
264 "Error unexpected lookup node %" PRIu64
"\n",
271 printf("Test #4: remove keys (8-bit).\n");
272 for (key
= 0; key
< 200; key
++) {
273 struct cds_hlist_head head
;
274 struct ja_test_node
*node
;
277 head
= cds_ja_lookup(test_ja
, key
);
278 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
280 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
283 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
285 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
288 call_rcu(&node
->node
.head
, free_node_cb
);
289 head
= cds_ja_lookup(test_ja
, key
);
290 if (!cds_hlist_empty(&head
)) {
291 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
298 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
300 fprintf(stderr
, "Error destroying judy array\n");
307 int test_16bit_key(void)
312 /* Test with 16-bit key */
313 test_ja
= cds_ja_new(16);
315 printf("Error allocating judy array.\n");
320 printf("Test #1: add keys (16-bit).\n");
321 for (key
= 0; key
< 10000; key
++) {
322 //for (key = 0; key < 65536; key+=256) {
323 struct ja_test_node
*node
= node_alloc();
325 ja_test_node_init(node
, key
);
327 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
330 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
337 printf("Test #2: successful key lookup (16-bit).\n");
338 for (key
= 0; key
< 10000; key
++) {
339 //for (key = 0; key < 65536; key+=256) {
340 struct cds_hlist_head head
;
343 head
= cds_ja_lookup(test_ja
, key
);
344 if (cds_hlist_empty(&head
)) {
345 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
351 printf("Test #3: unsuccessful key lookup (16-bit).\n");
352 for (key
= 11000; key
<= 11002; key
++) {
353 struct cds_hlist_head head
;
356 head
= cds_ja_lookup(test_ja
, key
);
357 if (!cds_hlist_empty(&head
)) {
359 "Error unexpected lookup node %" PRIu64
"\n",
366 printf("Test #4: remove keys (16-bit).\n");
367 for (key
= 0; key
< 10000; key
++) {
368 //for (key = 0; key < 65536; key+=256) {
369 struct cds_hlist_head head
;
370 struct ja_test_node
*node
;
373 head
= cds_ja_lookup(test_ja
, key
);
374 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
376 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
379 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
381 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
384 call_rcu(&node
->node
.head
, free_node_cb
);
385 head
= cds_ja_lookup(test_ja
, key
);
386 if (!cds_hlist_empty(&head
)) {
387 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
394 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
396 fprintf(stderr
, "Error destroying judy array\n");
403 * nr_dup is number of nodes per key.
406 int test_sparse_key(unsigned int bits
, int nr_dup
)
408 uint64_t key
, max_key
;
409 int zerocount
, i
, ret
;
412 max_key
= UINT64_MAX
;
414 max_key
= (1ULL << bits
) - 1;
416 printf("Sparse key test begins for %u-bit keys\n", bits
);
417 /* Test with 16-bit key */
418 test_ja
= cds_ja_new(bits
);
420 printf("Error allocating judy array.\n");
425 printf("Test #1: add keys (%u-bit).\n", bits
);
426 for (i
= 0; i
< nr_dup
; i
++) {
428 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
429 struct ja_test_node
*node
= node_alloc();
431 ja_test_node_init(node
, key
);
433 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
436 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
446 printf("Test #2: successful key lookup (%u-bit).\n", bits
);
448 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
449 struct cds_hlist_head head
;
450 struct ja_test_node
*node
;
451 struct cds_hlist_node
*pos
;
455 head
= cds_ja_lookup(test_ja
, key
);
456 if (cds_hlist_empty(&head
)) {
457 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
460 cds_hlist_for_each_entry_rcu(node
, pos
, &head
, node
.list
) {
463 if (count
!= nr_dup
) {
464 fprintf(stderr
, "Unexpected number of match for key %" PRIu64
", expected %d, got %d.\n", key
, nr_dup
, count
);
472 printf("Test #3: unsuccessful key lookup (%u-bit).\n", bits
);
474 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
475 struct cds_hlist_head head
;
478 head
= cds_ja_lookup(test_ja
, key
+ 42);
479 if (!cds_hlist_empty(&head
)) {
481 "Error unexpected lookup node %" PRIu64
"\n",
491 printf("Test #4: remove keys (%u-bit).\n", bits
);
493 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
494 struct cds_hlist_head head
;
495 struct ja_test_node
*node
;
496 struct cds_hlist_node
*pos
;
500 head
= cds_ja_lookup(test_ja
, key
);
503 cds_hlist_for_each_entry_rcu(node
, pos
, &head
, node
.list
) {
504 struct cds_hlist_head testhead
;
508 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
511 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
513 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
516 call_rcu(&node
->node
.head
, free_node_cb
);
517 testhead
= cds_ja_lookup(test_ja
, key
);
518 if (count
< nr_dup
&& cds_hlist_empty(&testhead
)) {
519 fprintf(stderr
, "Error: no node found after deletion of some nodes of a key\n");
523 head
= cds_ja_lookup(test_ja
, key
);
524 if (!cds_hlist_empty(&head
)) {
525 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
534 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
536 fprintf(stderr
, "Error destroying judy array\n");
539 printf("Test ends\n");
545 int do_sanity_test(void)
549 printf("Sanity test start.\n");
551 for (i
= 0; i
< 3; i
++) {
552 ret
= test_8bit_key();
556 rcu_quiescent_state();
558 ret
= test_16bit_key();
562 rcu_quiescent_state();
565 for (i
= 8; i
<= 64; i
*= 2) {
566 /* nr of nodes per key */
567 for (j
= 1; j
< 4; j
++) {
568 ret
= test_sparse_key(i
, j
);
572 rcu_quiescent_state();
575 printf("Sanity test end.\n");
580 enum urcu_ja_addremove
{
584 }; /* 1: add, -1 remove, 0: random */
586 static enum urcu_ja_addremove addremove
; /* 1: add, -1 remove, 0: random */
589 void test_ja_rw_sigusr1_handler(int signo
)
593 printf("Add/Remove: random.\n");
594 addremove
= AR_RANDOM
;
597 printf("Add/Remove: remove only.\n");
598 addremove
= AR_REMOVE
;
601 printf("Add/Remove: add only.\n");
608 void *test_ja_rw_thr_reader(void *_count
)
610 unsigned long long *count
= _count
;
611 struct cds_hlist_head head
;
614 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
615 "reader", pthread_self(), (unsigned long) gettid());
619 rcu_register_thread();
629 /* note: only looking up ulong keys */
630 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % lookup_pool_size
) + lookup_pool_offset
;
632 head
= cds_ja_lookup(test_ja
, key
);
633 if (cds_hlist_empty(&head
)) {
634 if (validate_lookup
) {
635 printf("[ERROR] Lookup cannot find initial node.\n");
638 URCU_TLS(lookup_fail
)++;
640 URCU_TLS(lookup_ok
)++;
642 rcu_debug_yield_read();
643 if (caa_unlikely(rduration
))
644 loop_sleep(rduration
);
646 URCU_TLS(nr_reads
)++;
647 if (caa_unlikely(!test_duration_read()))
649 if (caa_unlikely((URCU_TLS(nr_reads
) & ((1 << 10) - 1)) == 0))
650 rcu_quiescent_state();
653 rcu_unregister_thread();
655 *count
= URCU_TLS(nr_reads
);
656 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
657 "reader", pthread_self(), (unsigned long) gettid());
658 printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
659 pthread_self(), URCU_TLS(lookup_fail
),
660 URCU_TLS(lookup_ok
));
667 return ((unsigned int) rand_r(&URCU_TLS(rand_lookup
)) % 100) < add_ratio
;
671 void *test_ja_rw_thr_writer(void *_count
)
673 struct wr_count
*count
= _count
;
674 struct cds_hlist_head head
;
678 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
679 "writer", pthread_self(), (unsigned long) gettid());
683 rcu_register_thread();
691 if ((addremove
== AR_ADD
)
692 || (addremove
== AR_RANDOM
&& is_add())) {
693 struct ja_test_node
*node
= node_alloc();
694 struct cds_ja_node
*ret_node
;
696 /* note: only inserting ulong keys */
697 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % write_pool_size
) + write_pool_offset
;
699 ja_test_node_init(node
, key
);
702 ret_node
= cds_ja_add_unique(test_ja
, key
, &node
->node
);
703 if (ret_node
!= &node
->node
) {
705 URCU_TLS(nr_addexist
)++;
709 } else if (add_replace
) {
710 assert(0); /* not implemented yet. */
712 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
714 fprintf(stderr
, "Error in cds_ja_add: %d\n", ret
);
722 struct ja_test_node
*node
;
725 /* note: only deleting ulong keys */
726 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % write_pool_size
) + write_pool_offset
;
731 head
= cds_ja_lookup(test_ja
, key
);
732 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
734 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
736 call_rcu(&node
->node
.head
, free_node_cb
);
739 URCU_TLS(nr_delnoent
)++;
742 URCU_TLS(nr_delnoent
)++;
747 URCU_TLS(nr_writes
)++;
748 if (caa_unlikely(!test_duration_write()))
750 if (caa_unlikely(wdelay
))
752 if (caa_unlikely((URCU_TLS(nr_writes
) & ((1 << 10) - 1)) == 0))
753 rcu_quiescent_state();
756 rcu_unregister_thread();
758 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
759 "writer", pthread_self(), (unsigned long) gettid());
760 printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
761 "nr_delnoent %lu\n", pthread_self(), URCU_TLS(nr_add
),
762 URCU_TLS(nr_addexist
), URCU_TLS(nr_del
),
763 URCU_TLS(nr_delnoent
));
764 count
->update_ops
= URCU_TLS(nr_writes
);
765 count
->add
= URCU_TLS(nr_add
);
766 count
->add_exist
= URCU_TLS(nr_addexist
);
767 count
->remove
= URCU_TLS(nr_del
);
772 int do_mt_populate_ja(void)
774 struct cds_hlist_head head
;
781 printf("Starting rw test\n");
783 for (iter
= init_pool_offset
; iter
< init_pool_offset
+ init_pool_size
; iter
++) {
784 struct ja_test_node
*node
= node_alloc();
787 /* note: only inserting ulong keys */
788 key
= (unsigned long) iter
;
790 ja_test_node_init(node
, key
);
792 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
794 URCU_TLS(nr_writes
)++;
797 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
808 pthread_t
*tid_reader
, *tid_writer
;
811 unsigned long long *count_reader
;
812 struct wr_count
*count_writer
;
813 unsigned long long tot_reads
= 0, tot_writes
= 0,
814 tot_add
= 0, tot_add_exist
= 0, tot_remove
= 0;
817 tid_reader
= malloc(sizeof(*tid_reader
) * nr_readers
);
818 tid_writer
= malloc(sizeof(*tid_writer
) * nr_writers
);
819 count_reader
= malloc(sizeof(*count_reader
) * nr_readers
);
820 count_writer
= malloc(sizeof(*count_writer
) * nr_writers
);
822 printf("Allocating Judy Array for %u-bit keys\n", key_bits
);
823 test_ja
= cds_ja_new(key_bits
);
825 printf("Error allocating judy array.\n");
834 for (i
= 0; i
< nr_readers
; i
++) {
835 err
= pthread_create(&tid_reader
[i
],
836 NULL
, test_ja_rw_thr_reader
,
841 for (i
= 0; i
< nr_writers
; i
++) {
842 err
= pthread_create(&tid_writer
[i
],
843 NULL
, test_ja_rw_thr_writer
,
853 rcu_thread_offline_qsbr();
857 remain
= sleep(remain
);
858 } while (remain
> 0);
862 for (i
= 0; i
< nr_readers
; i
++) {
863 err
= pthread_join(tid_reader
[i
], &tret
);
866 tot_reads
+= count_reader
[i
];
868 for (i
= 0; i
< nr_writers
; i
++) {
869 err
= pthread_join(tid_writer
[i
], &tret
);
872 tot_writes
+= count_writer
[i
].update_ops
;
873 tot_add
+= count_writer
[i
].add
;
874 tot_add_exist
+= count_writer
[i
].add_exist
;
875 tot_remove
+= count_writer
[i
].remove
;
877 rcu_thread_online_qsbr();
879 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
881 fprintf(stderr
, "Error destroying judy array\n");
895 int check_memory_leaks(void)
897 unsigned long na
, nf
;
899 na
= uatomic_read(&test_nodes_allocated
);
900 nf
= uatomic_read(&test_nodes_freed
);
902 fprintf(stderr
, "Memory leak of %ld test nodes detected. Allocated: %lu, freed: %lu\n",
909 int main(int argc
, char **argv
)
911 int i
, j
, a
, ret
, err
;
913 struct sigaction act
;
916 show_usage(argc
, argv
);
920 err
= sscanf(argv
[1], "%u", &nr_readers
);
922 show_usage(argc
, argv
);
926 err
= sscanf(argv
[2], "%u", &nr_writers
);
928 show_usage(argc
, argv
);
932 err
= sscanf(argv
[3], "%lu", &duration
);
934 show_usage(argc
, argv
);
938 for (i
= 4; i
< argc
; i
++) {
939 if (argv
[i
][0] != '-')
941 switch (argv
[i
][1]) {
944 yield_active
|= YIELD_READ
;
947 yield_active
|= YIELD_WRITE
;
952 show_usage(argc
, argv
);
956 cpu_affinities
[next_aff
++] = a
;
958 printf_verbose("Adding CPU %d affinity\n", a
);
962 show_usage(argc
, argv
);
965 rduration
= atol(argv
[++i
]);
969 show_usage(argc
, argv
);
972 wdelay
= atol(argv
[++i
]);
978 add_ratio
= atoi(argv
[++i
]);
984 lookup_pool_offset
= atol(argv
[++i
]);
987 write_pool_offset
= atol(argv
[++i
]);
990 init_pool_offset
= atol(argv
[++i
]);
993 lookup_pool_size
= atol(argv
[++i
]);
996 write_pool_size
= atol(argv
[++i
]);
999 init_pool_size
= atol(argv
[++i
]);
1002 validate_lookup
= 1;
1008 key_bits
= atol(argv
[++i
]);
1011 key_mul
= atoll(argv
[++i
]);
1025 printf_verbose("running test for %lu seconds, %u readers, %u writers.\n",
1026 duration
, nr_readers
, nr_writers
);
1027 printf_verbose("Writer delay : %lu loops.\n", wdelay
);
1028 printf_verbose("Reader duration : %lu loops.\n", rduration
);
1029 printf_verbose("Add ratio: %u%%.\n", add_ratio
);
1030 printf_verbose("Mode:%s%s.\n",
1032 add_unique
? " uniquify" : ( add_replace
? " replace" : " insert"));
1033 printf_verbose("Key multiplication factor: %" PRIu64
".\n", key_mul
);
1034 printf_verbose("Init pool size offset %lu size %lu.\n",
1035 init_pool_offset
, init_pool_size
);
1036 printf_verbose("Lookup pool size offset %lu size %lu.\n",
1037 lookup_pool_offset
, lookup_pool_size
);
1038 printf_verbose("Update pool size offset %lu size %lu.\n",
1039 write_pool_offset
, write_pool_size
);
1040 if (validate_lookup
)
1041 printf_verbose("Validating lookups.\n");
1043 printf_verbose("Memory leak dection activated.\n");
1044 printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
1045 "main", pthread_self(), (unsigned long)gettid());
1047 memset(&act
, 0, sizeof(act
));
1048 ret
= sigemptyset(&act
.sa_mask
);
1050 perror("sigemptyset");
1053 act
.sa_handler
= test_ja_rw_sigusr1_handler
;
1054 act
.sa_flags
= SA_RESTART
;
1055 ret
= sigaction(SIGUSR1
, &act
, NULL
);
1057 perror("sigaction");
1061 err
= create_all_cpu_call_rcu_data(0);
1063 printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n");
1066 rcu_register_thread();
1069 ret
= do_sanity_test();
1074 /* Wait for in-flight call_rcu free to complete for leak detection */
1077 ret
|= check_memory_leaks();
1079 rcu_unregister_thread();
1080 free_all_cpu_call_rcu_data();
1083 printf("Test ended with error: %d\n", ret
);