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 pthread_mutex_t rcu_copy_mutex
= PTHREAD_MUTEX_INITIALIZER
;
76 void set_affinity(void)
85 #if HAVE_SCHED_SETAFFINITY
86 ret
= pthread_mutex_lock(&affinity_mutex
);
88 perror("Error in pthread mutex lock");
91 cpu
= cpu_affinities
[next_aff
++];
92 ret
= pthread_mutex_unlock(&affinity_mutex
);
94 perror("Error in pthread mutex unlock");
99 #if SCHED_SETAFFINITY_ARGS == 2
100 sched_setaffinity(0, &mask
);
102 sched_setaffinity(0, sizeof(mask
), &mask
);
104 #endif /* HAVE_SCHED_SETAFFINITY */
107 void rcu_copy_mutex_lock(void)
110 ret
= pthread_mutex_lock(&rcu_copy_mutex
);
112 perror("Error in pthread mutex lock");
117 void rcu_copy_mutex_unlock(void)
121 ret
= pthread_mutex_unlock(&rcu_copy_mutex
);
123 perror("Error in pthread mutex unlock");
128 void free_node_cb(struct rcu_head
*head
)
130 struct ja_test_node
*node
=
131 caa_container_of(head
, struct ja_test_node
, node
.head
);
137 void test_delete_all_nodes(struct cds_lfht
*ht
)
139 struct cds_lfht_iter iter
;
140 struct lfht_test_node
*node
;
141 unsigned long count
= 0;
143 cds_lfht_for_each_entry(ht
, &iter
, node
, node
) {
146 ret
= cds_lfht_del(test_ht
, cds_lfht_iter_get_node(&iter
));
148 call_rcu(&node
->head
, free_node_cb
);
151 printf("deleted %lu nodes.\n", count
);
155 void show_usage(int argc
, char **argv
)
157 printf("Usage : %s nr_readers nr_writers duration (s)\n", argv
[0]);
159 printf(" [-r] [-w] (yield reader and/or writer)\n");
161 printf(" [-d delay] (writer period (us))\n");
162 printf(" [-c duration] (reader C.S. duration (in loops))\n");
163 printf(" [-v] (verbose output)\n");
164 printf(" [-a cpu#] [-a cpu#]... (affinity)\n");
165 printf(" [not -u nor -s] Add entries (supports redundant keys).\n");
166 printf(" [-i] Add only (no removal).\n");
167 printf(" [-k nr_nodes] Number of nodes to insert initially.\n");
168 printf(" [-R offset] Lookup pool offset.\n");
169 printf(" [-S offset] Write pool offset.\n");
170 printf(" [-T offset] Init pool offset.\n");
171 printf(" [-M size] Lookup pool size.\n");
172 printf(" [-N size] Write pool size.\n");
173 printf(" [-O size] Init pool size.\n");
174 printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).\n");
175 printf(" [-s] Do sanity test.\n");
176 printf(" [-B] Key bits for multithread test (default: 32).\n");
182 int test_8bit_key(void)
187 /* Test with 8-bit key */
188 test_ja
= cds_ja_new(8);
190 printf("Error allocating judy array.\n");
195 printf("Test #1: add keys (8-bit).\n");
196 for (key
= 0; key
< 200; key
++) {
197 struct ja_test_node
*node
=
198 calloc(sizeof(*node
), 1);
200 ja_test_node_init(node
, key
);
202 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
205 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
212 printf("Test #2: successful key lookup (8-bit).\n");
213 for (key
= 0; key
< 200; key
++) {
214 struct cds_hlist_head head
;
217 head
= cds_ja_lookup(test_ja
, key
);
218 if (cds_hlist_empty(&head
)) {
219 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
225 printf("Test #3: unsuccessful key lookup (8-bit).\n");
226 for (key
= 200; key
< 240; key
++) {
227 struct cds_hlist_head head
;
230 head
= cds_ja_lookup(test_ja
, key
);
231 if (!cds_hlist_empty(&head
)) {
233 "Error unexpected lookup node %" PRIu64
"\n",
240 printf("Test #4: remove keys (8-bit).\n");
241 for (key
= 0; key
< 200; key
++) {
242 struct cds_hlist_head head
;
243 struct ja_test_node
*node
;
246 head
= cds_ja_lookup(test_ja
, key
);
247 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
249 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
252 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
254 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
257 call_rcu(&node
->node
.head
, free_node_cb
);
258 head
= cds_ja_lookup(test_ja
, key
);
259 if (!cds_hlist_empty(&head
)) {
260 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
267 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
269 fprintf(stderr
, "Error destroying judy array\n");
276 int test_16bit_key(void)
281 /* Test with 16-bit key */
282 test_ja
= cds_ja_new(16);
284 printf("Error allocating judy array.\n");
289 printf("Test #1: add keys (16-bit).\n");
290 for (key
= 0; key
< 10000; key
++) {
291 //for (key = 0; key < 65536; key+=256) {
292 struct ja_test_node
*node
=
293 calloc(sizeof(*node
), 1);
295 ja_test_node_init(node
, key
);
297 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
300 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
307 printf("Test #2: successful key lookup (16-bit).\n");
308 for (key
= 0; key
< 10000; key
++) {
309 //for (key = 0; key < 65536; key+=256) {
310 struct cds_hlist_head head
;
313 head
= cds_ja_lookup(test_ja
, key
);
314 if (cds_hlist_empty(&head
)) {
315 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
321 printf("Test #3: unsuccessful key lookup (16-bit).\n");
322 for (key
= 11000; key
<= 11002; key
++) {
323 struct cds_hlist_head head
;
326 head
= cds_ja_lookup(test_ja
, key
);
327 if (!cds_hlist_empty(&head
)) {
329 "Error unexpected lookup node %" PRIu64
"\n",
336 printf("Test #4: remove keys (16-bit).\n");
337 for (key
= 0; key
< 10000; key
++) {
338 //for (key = 0; key < 65536; key+=256) {
339 struct cds_hlist_head head
;
340 struct ja_test_node
*node
;
343 head
= cds_ja_lookup(test_ja
, key
);
344 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
346 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
349 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
351 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
354 call_rcu(&node
->node
.head
, free_node_cb
);
355 head
= cds_ja_lookup(test_ja
, key
);
356 if (!cds_hlist_empty(&head
)) {
357 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
364 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
366 fprintf(stderr
, "Error destroying judy array\n");
373 * nr_dup is number of nodes per key.
376 int test_sparse_key(unsigned int bits
, int nr_dup
)
378 uint64_t key
, max_key
;
379 int zerocount
, i
, ret
;
382 max_key
= UINT64_MAX
;
384 max_key
= (1ULL << bits
) - 1;
386 printf("Sparse key test begins for %u-bit keys\n", bits
);
387 /* Test with 16-bit key */
388 test_ja
= cds_ja_new(bits
);
390 printf("Error allocating judy array.\n");
395 printf("Test #1: add keys (%u-bit).\n", bits
);
396 for (i
= 0; i
< nr_dup
; i
++) {
398 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
399 struct ja_test_node
*node
=
400 calloc(sizeof(*node
), 1);
402 ja_test_node_init(node
, key
);
404 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
407 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
417 printf("Test #2: successful key lookup (%u-bit).\n", bits
);
419 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
420 struct cds_hlist_head head
;
421 struct ja_test_node
*node
;
422 struct cds_hlist_node
*pos
;
426 head
= cds_ja_lookup(test_ja
, key
);
427 if (cds_hlist_empty(&head
)) {
428 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
431 cds_hlist_for_each_entry_rcu(node
, pos
, &head
, node
.list
) {
434 if (count
!= nr_dup
) {
435 fprintf(stderr
, "Unexpected number of match for key %" PRIu64
", expected %d, got %d.\n", key
, nr_dup
, count
);
443 printf("Test #3: unsuccessful key lookup (%u-bit).\n", bits
);
445 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
446 struct cds_hlist_head head
;
449 head
= cds_ja_lookup(test_ja
, key
+ 42);
450 if (!cds_hlist_empty(&head
)) {
452 "Error unexpected lookup node %" PRIu64
"\n",
462 printf("Test #4: remove keys (16-bit).\n");
464 for (key
= 0; key
<= max_key
&& (key
!= 0 || zerocount
< 1); key
+= 1ULL << (bits
- 8)) {
465 struct cds_hlist_head head
;
466 struct ja_test_node
*node
;
467 struct cds_hlist_node
*pos
;
471 head
= cds_ja_lookup(test_ja
, key
);
474 cds_hlist_for_each_entry_rcu(node
, pos
, &head
, node
.list
) {
475 struct cds_hlist_head testhead
;
479 fprintf(stderr
, "Error lookup node %" PRIu64
"\n", key
);
482 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
484 fprintf(stderr
, "Error (%d) removing node %" PRIu64
"\n", ret
, key
);
487 call_rcu(&node
->node
.head
, free_node_cb
);
488 testhead
= cds_ja_lookup(test_ja
, key
);
489 if (count
< nr_dup
&& cds_hlist_empty(&testhead
)) {
490 fprintf(stderr
, "Error: no node found after deletion of some nodes of a key\n");
494 head
= cds_ja_lookup(test_ja
, key
);
495 if (!cds_hlist_empty(&head
)) {
496 fprintf(stderr
, "Error lookup %" PRIu64
": %p (after delete) failed. Node is not expected.\n", key
, head
.next
);
505 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
507 fprintf(stderr
, "Error destroying judy array\n");
510 printf("Test ends\n");
516 int do_sanity_test(void)
520 printf("Sanity test start.\n");
522 for (i
= 0; i
< 3; i
++) {
523 ret
= test_8bit_key();
527 rcu_quiescent_state();
529 ret
= test_16bit_key();
533 rcu_quiescent_state();
536 for (i
= 8; i
<= 64; i
*= 2) {
537 /* nr of nodes per key */
538 for (j
= 1; j
< 4; j
++) {
539 ret
= test_sparse_key(i
, j
);
543 rcu_quiescent_state();
546 printf("Sanity test end.\n");
551 enum urcu_ja_addremove
{
555 }; /* 1: add, -1 remove, 0: random */
557 static enum urcu_ja_addremove addremove
; /* 1: add, -1 remove, 0: random */
560 void test_ja_rw_sigusr1_handler(int signo
)
564 printf("Add/Remove: random.\n");
565 addremove
= AR_RANDOM
;
568 printf("Add/Remove: remove only.\n");
569 addremove
= AR_REMOVE
;
572 printf("Add/Remove: add only.\n");
579 void *test_ja_rw_thr_reader(void *_count
)
581 unsigned long long *count
= _count
;
582 struct cds_hlist_head head
;
585 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
586 "reader", pthread_self(), (unsigned long) gettid());
590 rcu_register_thread();
600 /* note: only looking up ulong keys */
601 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % lookup_pool_size
) + lookup_pool_offset
;
602 head
= cds_ja_lookup(test_ja
, key
);
603 if (cds_hlist_empty(&head
)) {
604 if (validate_lookup
) {
605 printf("[ERROR] Lookup cannot find initial node.\n");
608 URCU_TLS(lookup_fail
)++;
610 URCU_TLS(lookup_ok
)++;
612 rcu_debug_yield_read();
613 if (caa_unlikely(rduration
))
614 loop_sleep(rduration
);
616 URCU_TLS(nr_reads
)++;
617 if (caa_unlikely(!test_duration_read()))
619 if (caa_unlikely((URCU_TLS(nr_reads
) & ((1 << 10) - 1)) == 0))
620 rcu_quiescent_state();
623 rcu_unregister_thread();
625 *count
= URCU_TLS(nr_reads
);
626 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
627 "reader", pthread_self(), (unsigned long) gettid());
628 printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
629 pthread_self(), URCU_TLS(lookup_fail
),
630 URCU_TLS(lookup_ok
));
635 void *test_ja_rw_thr_writer(void *_count
)
637 struct wr_count
*count
= _count
;
638 struct cds_hlist_head head
;
642 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
643 "writer", pthread_self(), (unsigned long) gettid());
647 rcu_register_thread();
655 if ((addremove
== AR_ADD
|| add_only
)
656 || (addremove
== AR_RANDOM
&& rand_r(&URCU_TLS(rand_lookup
)) & 1)) {
657 struct ja_test_node
*node
= malloc(sizeof(*node
));
659 /* note: only inserting ulong keys */
660 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % write_pool_size
) + write_pool_offset
;
661 ja_test_node_init(node
, key
);
663 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
667 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
672 struct ja_test_node
*node
;
675 /* note: only deleting ulong keys */
676 key
= ((unsigned long) rand_r(&URCU_TLS(rand_lookup
)) % write_pool_size
) + write_pool_offset
;
680 head
= cds_ja_lookup(test_ja
, key
);
681 node
= cds_hlist_first_entry_rcu(&head
, struct ja_test_node
, node
.list
);
683 ret
= cds_ja_del(test_ja
, key
, &node
->node
);
685 call_rcu(&node
->node
.head
, free_node_cb
);
686 URCU_TLS(nr_delnoent
)++;
691 URCU_TLS(nr_delnoent
)++;
695 URCU_TLS(nr_writes
)++;
696 if (caa_unlikely(!test_duration_write()))
698 if (caa_unlikely(wdelay
))
700 if (caa_unlikely((URCU_TLS(nr_writes
) & ((1 << 10) - 1)) == 0))
701 rcu_quiescent_state();
704 rcu_unregister_thread();
706 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
707 "writer", pthread_self(), (unsigned long) gettid());
708 printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
709 "nr_delnoent %lu\n", pthread_self(), URCU_TLS(nr_add
),
710 URCU_TLS(nr_addexist
), URCU_TLS(nr_del
),
711 URCU_TLS(nr_delnoent
));
712 count
->update_ops
= URCU_TLS(nr_writes
);
713 count
->add
= URCU_TLS(nr_add
);
714 count
->add_exist
= URCU_TLS(nr_addexist
);
715 count
->remove
= URCU_TLS(nr_del
);
720 int do_mt_populate_ja(void)
722 struct cds_hlist_head head
;
729 printf("Starting rw test\n");
731 for (key
= init_pool_offset
; key
< init_pool_offset
+ init_pool_size
; key
++) {
732 struct ja_test_node
*node
= malloc(sizeof(*node
));
734 /* note: only inserting ulong keys */
735 key
= (unsigned long) key
;
736 ja_test_node_init(node
, key
);
738 ret
= cds_ja_add(test_ja
, key
, &node
->node
);
740 URCU_TLS(nr_writes
)++;
743 fprintf(stderr
, "Error (%d) adding node %" PRIu64
"\n",
754 pthread_t
*tid_reader
, *tid_writer
;
757 unsigned long long *count_reader
;
758 struct wr_count
*count_writer
;
759 unsigned long long tot_reads
= 0, tot_writes
= 0,
760 tot_add
= 0, tot_add_exist
= 0, tot_remove
= 0;
763 tid_reader
= malloc(sizeof(*tid_reader
) * nr_readers
);
764 tid_writer
= malloc(sizeof(*tid_writer
) * nr_writers
);
765 count_reader
= malloc(sizeof(*count_reader
) * nr_readers
);
766 count_writer
= malloc(sizeof(*count_writer
) * nr_writers
);
768 printf("Allocating Judy Array for %u-bit keys\n", key_bits
);
769 test_ja
= cds_ja_new(key_bits
);
771 printf("Error allocating judy array.\n");
780 for (i
= 0; i
< nr_readers
; i
++) {
781 err
= pthread_create(&tid_reader
[i
],
782 NULL
, test_ja_rw_thr_reader
,
787 for (i
= 0; i
< nr_writers
; i
++) {
788 err
= pthread_create(&tid_writer
[i
],
789 NULL
, test_ja_rw_thr_writer
,
799 rcu_thread_offline_qsbr();
803 remain
= sleep(remain
);
804 } while (remain
> 0);
808 for (i
= 0; i
< nr_readers
; i
++) {
809 err
= pthread_join(tid_reader
[i
], &tret
);
812 tot_reads
+= count_reader
[i
];
814 for (i
= 0; i
< nr_writers
; i
++) {
815 err
= pthread_join(tid_writer
[i
], &tret
);
818 tot_writes
+= count_writer
[i
].update_ops
;
819 tot_add
+= count_writer
[i
].add
;
820 tot_add_exist
+= count_writer
[i
].add_exist
;
821 tot_remove
+= count_writer
[i
].remove
;
824 ret
= cds_ja_destroy(test_ja
, free_node_cb
);
826 fprintf(stderr
, "Error destroying judy array\n");
829 rcu_thread_online_qsbr();
840 int main(int argc
, char **argv
)
842 int i
, j
, a
, ret
, err
;
844 struct sigaction act
;
847 show_usage(argc
, argv
);
851 err
= sscanf(argv
[1], "%u", &nr_readers
);
853 show_usage(argc
, argv
);
857 err
= sscanf(argv
[2], "%u", &nr_writers
);
859 show_usage(argc
, argv
);
863 err
= sscanf(argv
[3], "%lu", &duration
);
865 show_usage(argc
, argv
);
869 for (i
= 4; i
< argc
; i
++) {
870 if (argv
[i
][0] != '-')
872 switch (argv
[i
][1]) {
875 yield_active
|= YIELD_READ
;
878 yield_active
|= YIELD_WRITE
;
883 show_usage(argc
, argv
);
887 cpu_affinities
[next_aff
++] = a
;
889 printf_verbose("Adding CPU %d affinity\n", a
);
893 show_usage(argc
, argv
);
896 rduration
= atol(argv
[++i
]);
900 show_usage(argc
, argv
);
903 wdelay
= atol(argv
[++i
]);
912 init_populate
= atol(argv
[++i
]);
915 lookup_pool_offset
= atol(argv
[++i
]);
918 write_pool_offset
= atol(argv
[++i
]);
921 init_pool_offset
= atol(argv
[++i
]);
924 lookup_pool_size
= atol(argv
[++i
]);
927 write_pool_size
= atol(argv
[++i
]);
930 init_pool_size
= atol(argv
[++i
]);
939 key_bits
= atol(argv
[++i
]);
944 printf_verbose("running test for %lu seconds, %u readers, %u writers.\n",
945 duration
, nr_readers
, nr_writers
);
946 printf_verbose("Writer delay : %lu loops.\n", wdelay
);
947 printf_verbose("Reader duration : %lu loops.\n", rduration
);
948 printf_verbose("Mode:%s.\n",
949 add_only
? " add only" : " add/delete");
950 printf_verbose("Init pool size offset %lu size %lu.\n",
951 init_pool_offset
, init_pool_size
);
952 printf_verbose("Lookup pool size offset %lu size %lu.\n",
953 lookup_pool_offset
, lookup_pool_size
);
954 printf_verbose("Update pool size offset %lu size %lu.\n",
955 write_pool_offset
, write_pool_size
);
956 printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
957 "main", pthread_self(), (unsigned long)gettid());
959 memset(&act
, 0, sizeof(act
));
960 ret
= sigemptyset(&act
.sa_mask
);
962 perror("sigemptyset");
965 act
.sa_handler
= test_ja_rw_sigusr1_handler
;
966 act
.sa_flags
= SA_RESTART
;
967 ret
= sigaction(SIGUSR1
, &act
, NULL
);
973 err
= create_all_cpu_call_rcu_data(0);
975 printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n");
978 rcu_register_thread();
981 ret
= do_sanity_test();
983 fprintf(stderr
, "Error in sanity test\n");
989 rcu_unregister_thread();
990 free_all_cpu_call_rcu_data();
995 * Hash Population needs to be seen as a RCU reader
996 * thread from the point of view of resize.
998 rcu_register_thread();
999 ret
= (get_populate_hash_cb())();
1002 rcu_thread_offline();
1004 /* teardown counter thread */
1005 act
.sa_handler
= SIG_IGN
;
1006 act
.sa_flags
= SA_RESTART
;
1007 ret
= sigaction(SIGUSR2
, &act
, NULL
);
1009 perror("sigaction");
1013 char msg
[1] = { 0x42 };
1017 ret
= write(count_pipe
[1], msg
, 1); /* wakeup thread */
1018 } while (ret
== -1L && errno
== EINTR
);
1022 rcu_thread_online();
1024 printf("Counting nodes... ");
1025 cds_lfht_count_nodes(test_ht
, &approx_before
, &count
, &approx_after
);
1027 test_delete_all_nodes(test_ht
);
1029 rcu_thread_offline();
1031 printf("Approximation before node accounting: %ld nodes.\n",
1033 printf("Nodes deleted from hash table before destroy: "
1036 printf("Approximation after node accounting: %ld nodes.\n",
1039 ret
= cds_lfht_destroy(test_ht
, NULL
);
1041 printf_verbose("final delete aborted\n");
1043 printf_verbose("final delete success\n");
1044 printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads
,
1046 printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu "
1048 "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu "
1049 "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n",
1050 argv
[0], duration
, nr_readers
, rduration
,
1051 nr_writers
, wdelay
, tot_reads
, tot_writes
,
1052 tot_reads
+ tot_writes
, tot_add
, tot_add_exist
, tot_remove
,
1053 (long long) tot_add
+ init_populate
- tot_remove
- count
);
1054 rcu_unregister_thread();