rculfhash test: allow different size for lookup, write, init
[urcu.git] / tests / test_urcu_hash.c
1 /*
2 * test_urcu_hash.c
3 *
4 * Userspace RCU library - test program
5 *
6 * Copyright February 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 *
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.
12 *
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.
17 *
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.
21 */
22
23 #define _GNU_SOURCE
24 #include <stdio.h>
25 #include <pthread.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <sys/wait.h>
30 #include <unistd.h>
31 #include <stdio.h>
32 #include <assert.h>
33 #include <sched.h>
34 #include <errno.h>
35
36 #ifdef __linux__
37 #include <syscall.h>
38 #endif
39
40 #define DEFAULT_HASH_SIZE 32
41 #define DEFAULT_RAND_POOL 1000000
42
43 /* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
44 #define CACHE_LINE_SIZE 4096
45
46 /* hardcoded number of CPUs */
47 #define NR_CPUS 16384
48
49 #ifdef POISON_FREE
50 #define poison_free(ptr) \
51 do { \
52 memset(ptr, 0x42, sizeof(*(ptr))); \
53 free(ptr); \
54 } while (0)
55 #else
56 #define poison_free(ptr) free(ptr)
57 #endif
58
59
60
61 #if defined(_syscall0)
62 _syscall0(pid_t, gettid)
63 #elif defined(__NR_gettid)
64 static inline pid_t gettid(void)
65 {
66 return syscall(__NR_gettid);
67 }
68 #else
69 #warning "use pid as tid"
70 static inline pid_t gettid(void)
71 {
72 return getpid();
73 }
74 #endif
75
76 #ifndef DYNAMIC_LINK_TEST
77 #define _LGPL_SOURCE
78 #else
79 #define debug_yield_read()
80 #endif
81 #include <urcu-qsbr.h>
82 #include <urcu/rculfhash.h>
83 #include <urcu-call-rcu.h>
84
85 struct wr_count {
86 unsigned long update_ops;
87 unsigned long add;
88 unsigned long add_exist;
89 unsigned long remove;
90 };
91
92 static unsigned int __thread rand_lookup;
93 static unsigned long __thread nr_add;
94 static unsigned long __thread nr_addexist;
95 static unsigned long __thread nr_del;
96 static unsigned long __thread nr_delnoent;
97 static unsigned long __thread lookup_fail;
98 static unsigned long __thread lookup_ok;
99
100 static struct cds_lfht *test_ht;
101
102 struct test_data {
103 int a;
104 int b;
105 };
106
107 static volatile int test_go, test_stop;
108
109 static unsigned long wdelay;
110
111 static unsigned long duration;
112
113 /* read-side C.S. duration, in loops */
114 static unsigned long rduration;
115
116 static unsigned long init_hash_size = DEFAULT_HASH_SIZE;
117 static unsigned long init_populate;
118 static int opt_auto_resize;
119 static int add_only, add_unique;
120
121 static unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset;
122 static unsigned long init_pool_size = DEFAULT_RAND_POOL,
123 lookup_pool_size = DEFAULT_RAND_POOL,
124 write_pool_size = DEFAULT_RAND_POOL;
125 static int validate_lookup;
126
127 static inline void loop_sleep(unsigned long l)
128 {
129 while(l-- != 0)
130 caa_cpu_relax();
131 }
132
133 static int verbose_mode;
134
135 #define printf_verbose(fmt, args...) \
136 do { \
137 if (verbose_mode) \
138 printf(fmt, ## args); \
139 } while (0)
140
141 static unsigned int cpu_affinities[NR_CPUS];
142 static unsigned int next_aff = 0;
143 static int use_affinity = 0;
144
145 pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
146
147 static void set_affinity(void)
148 {
149 cpu_set_t mask;
150 int cpu;
151 int ret;
152
153 if (!use_affinity)
154 return;
155
156 ret = pthread_mutex_lock(&affinity_mutex);
157 if (ret) {
158 perror("Error in pthread mutex lock");
159 exit(-1);
160 }
161 cpu = cpu_affinities[next_aff++];
162 ret = pthread_mutex_unlock(&affinity_mutex);
163 if (ret) {
164 perror("Error in pthread mutex unlock");
165 exit(-1);
166 }
167 CPU_ZERO(&mask);
168 CPU_SET(cpu, &mask);
169 sched_setaffinity(0, sizeof(mask), &mask);
170 }
171
172 static enum {
173 AR_RANDOM = 0,
174 AR_ADD = 1,
175 AR_REMOVE = -1,
176 } addremove; /* 1: add, -1 remove, 0: random */
177
178 static
179 void sigusr1_handler(int signo)
180 {
181 switch (addremove) {
182 case AR_ADD:
183 printf("Add/Remove: random.\n");
184 addremove = AR_RANDOM;
185 break;
186 case AR_RANDOM:
187 printf("Add/Remove: remove only.\n");
188 addremove = AR_REMOVE;
189 break;
190 case AR_REMOVE:
191 printf("Add/Remove: add only.\n");
192 addremove = AR_ADD;
193 break;
194 }
195 }
196
197 /*
198 * returns 0 if test should end.
199 */
200 static int test_duration_write(void)
201 {
202 return !test_stop;
203 }
204
205 static int test_duration_read(void)
206 {
207 return !test_stop;
208 }
209
210 static unsigned long long __thread nr_writes;
211 static unsigned long long __thread nr_reads;
212
213 static unsigned int nr_readers;
214 static unsigned int nr_writers;
215
216 pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER;
217
218 void rcu_copy_mutex_lock(void)
219 {
220 int ret;
221 ret = pthread_mutex_lock(&rcu_copy_mutex);
222 if (ret) {
223 perror("Error in pthread mutex lock");
224 exit(-1);
225 }
226 }
227
228 void rcu_copy_mutex_unlock(void)
229 {
230 int ret;
231
232 ret = pthread_mutex_unlock(&rcu_copy_mutex);
233 if (ret) {
234 perror("Error in pthread mutex unlock");
235 exit(-1);
236 }
237 }
238
239 /*
240 * Hash function
241 * Source: http://burtleburtle.net/bob/c/lookup3.c
242 * Originally Public Domain
243 */
244
245 #define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
246
247 #define mix(a, b, c) \
248 do { \
249 a -= c; a ^= rot(c, 4); c += b; \
250 b -= a; b ^= rot(a, 6); a += c; \
251 c -= b; c ^= rot(b, 8); b += a; \
252 a -= c; a ^= rot(c, 16); c += b; \
253 b -= a; b ^= rot(a, 19); a += c; \
254 c -= b; c ^= rot(b, 4); b += a; \
255 } while (0)
256
257 #define final(a, b, c) \
258 { \
259 c ^= b; c -= rot(b, 14); \
260 a ^= c; a -= rot(c, 11); \
261 b ^= a; b -= rot(a, 25); \
262 c ^= b; c -= rot(b, 16); \
263 a ^= c; a -= rot(c, 4);\
264 b ^= a; b -= rot(a, 14); \
265 c ^= b; c -= rot(b, 24); \
266 }
267
268 static __attribute__((unused))
269 uint32_t hash_u32(
270 const uint32_t *k, /* the key, an array of uint32_t values */
271 size_t length, /* the length of the key, in uint32_ts */
272 uint32_t initval) /* the previous hash, or an arbitrary value */
273 {
274 uint32_t a, b, c;
275
276 /* Set up the internal state */
277 a = b = c = 0xdeadbeef + (((uint32_t) length) << 2) + initval;
278
279 /*----------------------------------------- handle most of the key */
280 while (length > 3) {
281 a += k[0];
282 b += k[1];
283 c += k[2];
284 mix(a, b, c);
285 length -= 3;
286 k += 3;
287 }
288
289 /*----------------------------------- handle the last 3 uint32_t's */
290 switch (length) { /* all the case statements fall through */
291 case 3: c += k[2];
292 case 2: b += k[1];
293 case 1: a += k[0];
294 final(a, b, c);
295 case 0: /* case 0: nothing left to add */
296 break;
297 }
298 /*---------------------------------------------- report the result */
299 return c;
300 }
301
302 static
303 void hashword2(
304 const uint32_t *k, /* the key, an array of uint32_t values */
305 size_t length, /* the length of the key, in uint32_ts */
306 uint32_t *pc, /* IN: seed OUT: primary hash value */
307 uint32_t *pb) /* IN: more seed OUT: secondary hash value */
308 {
309 uint32_t a, b, c;
310
311 /* Set up the internal state */
312 a = b = c = 0xdeadbeef + ((uint32_t) (length << 2)) + *pc;
313 c += *pb;
314
315 /*----------------------------------------- handle most of the key */
316 while (length > 3) {
317 a += k[0];
318 b += k[1];
319 c += k[2];
320 mix(a, b, c);
321 length -= 3;
322 k += 3;
323 }
324
325 /*----------------------------------- handle the last 3 uint32_t's */
326 switch (length) { /* all the case statements fall through */
327 case 3: c += k[2];
328 case 2: b += k[1];
329 case 1: a += k[0];
330 final(a, b, c);
331 case 0: /* case 0: nothing left to add */
332 break;
333 }
334 /*---------------------------------------------- report the result */
335 *pc = c;
336 *pb = b;
337 }
338
339 #if (CAA_BITS_PER_LONG == 32)
340 static
341 unsigned long test_hash(void *_key, size_t length, unsigned long seed)
342 {
343 unsigned long key = (unsigned long) _key;
344 unsigned long v;
345
346 assert(length == sizeof(unsigned long));
347 return hash_u32(&v, 1, seed);
348 }
349 #else
350 static
351 unsigned long test_hash(void *_key, size_t length, unsigned long seed)
352 {
353 union {
354 uint64_t v64;
355 uint32_t v32[2];
356 } v;
357 union {
358 uint64_t v64;
359 uint32_t v32[2];
360 } key;
361
362 assert(length == sizeof(unsigned long));
363 v.v64 = (uint64_t) seed;
364 key.v64 = (uint64_t) _key;
365 hashword2(key.v32, 2, &v.v32[0], &v.v32[1]);
366 return v.v64;
367 }
368 #endif
369
370 static
371 unsigned long test_compare(void *key1, size_t key1_len,
372 void *key2, size_t key2_len)
373 {
374 if (unlikely(key1_len != key2_len))
375 return -1;
376 assert(key1_len == sizeof(unsigned long));
377 if (key1 == key2)
378 return 0;
379 else
380 return 1;
381 }
382
383 void *thr_reader(void *_count)
384 {
385 unsigned long long *count = _count;
386 struct cds_lfht_node *node;
387
388 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
389 "reader", pthread_self(), (unsigned long)gettid());
390
391 set_affinity();
392
393 rcu_register_thread();
394
395 while (!test_go)
396 {
397 }
398 cmm_smp_mb();
399
400 for (;;) {
401 rcu_read_lock();
402 node = cds_lfht_lookup(test_ht,
403 (void *)(unsigned long)((rand_r(&rand_lookup) % lookup_pool_size) + lookup_pool_offset),
404 sizeof(void *));
405 if (node == NULL) {
406 if (validate_lookup) {
407 printf("[ERROR] Lookup cannot find initial node.\n");
408 }
409 lookup_fail++;
410 } else {
411 lookup_ok++;
412 }
413 debug_yield_read();
414 if (unlikely(rduration))
415 loop_sleep(rduration);
416 rcu_read_unlock();
417 nr_reads++;
418 if (unlikely(!test_duration_read()))
419 break;
420 if (unlikely((nr_reads & ((1 << 10) - 1)) == 0))
421 rcu_quiescent_state();
422 }
423
424 rcu_unregister_thread();
425
426 *count = nr_reads;
427 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
428 "reader", pthread_self(), (unsigned long)gettid());
429 printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n",
430 pthread_self(), lookup_fail, lookup_ok);
431 return ((void*)1);
432
433 }
434
435 static
436 void free_node_cb(struct rcu_head *head)
437 {
438 struct cds_lfht_node *node =
439 caa_container_of(head, struct cds_lfht_node, head);
440 free(node);
441 }
442
443 void *thr_writer(void *_count)
444 {
445 struct cds_lfht_node *node, *ret_node;
446 struct wr_count *count = _count;
447 int ret;
448
449 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
450 "writer", pthread_self(), (unsigned long)gettid());
451
452 set_affinity();
453
454 rcu_register_thread();
455
456 while (!test_go)
457 {
458 }
459 cmm_smp_mb();
460
461 for (;;) {
462 if ((addremove == AR_ADD || add_only)
463 || (addremove == AR_RANDOM && rand_r(&rand_lookup) & 1)) {
464 node = malloc(sizeof(struct cds_lfht_node));
465 rcu_read_lock();
466 cds_lfht_node_init(node,
467 (void *)(unsigned long)((rand_r(&rand_lookup) % write_pool_size) + write_pool_offset),
468 sizeof(void *));
469 if (add_unique)
470 ret_node = cds_lfht_add_unique(test_ht, node);
471 else
472 cds_lfht_add(test_ht, node);
473 rcu_read_unlock();
474 if (add_unique && ret_node != node) {
475 free(node);
476 nr_addexist++;
477 } else
478 nr_add++;
479 } else {
480 /* May delete */
481 rcu_read_lock();
482 node = cds_lfht_lookup(test_ht,
483 (void *)(unsigned long)((rand_r(&rand_lookup) % write_pool_size) + write_pool_offset),
484 sizeof(void *));
485 if (node)
486 ret = cds_lfht_remove(test_ht, node);
487 else
488 ret = -ENOENT;
489 rcu_read_unlock();
490 if (ret == 0) {
491 call_rcu(&node->head, free_node_cb);
492 nr_del++;
493 } else
494 nr_delnoent++;
495 }
496 #if 0
497 //if (nr_writes % 100000 == 0) {
498 if (nr_writes % 1000 == 0) {
499 rcu_read_lock();
500 if (rand_r(&rand_lookup) & 1) {
501 ht_resize(test_ht, 1);
502 } else {
503 ht_resize(test_ht, -1);
504 }
505 rcu_read_unlock();
506 }
507 #endif //0
508 nr_writes++;
509 if (unlikely(!test_duration_write()))
510 break;
511 if (unlikely(wdelay))
512 loop_sleep(wdelay);
513 if (unlikely((nr_writes & ((1 << 10) - 1)) == 0))
514 rcu_quiescent_state();
515 }
516
517 rcu_unregister_thread();
518
519 printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
520 "writer", pthread_self(), (unsigned long)gettid());
521 printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, "
522 "nr_delnoent %lu\n", pthread_self(), nr_add,
523 nr_addexist, nr_del, nr_delnoent);
524 count->update_ops = nr_writes;
525 count->add = nr_add;
526 count->add_exist = nr_addexist;
527 count->remove = nr_del;
528 return ((void*)2);
529 }
530
531 static int populate_hash(void)
532 {
533 struct cds_lfht_node *node, *ret_node;
534
535 if (!init_populate)
536 return 0;
537
538 if (add_unique && init_populate * 10 > init_pool_size) {
539 printf("WARNING: required to populate %lu nodes (-k), but random "
540 "pool is quite small (%lu values) and we are in add_unique (-u) mode. Try with a "
541 "larger random pool (-p option). This may take a while...\n", init_populate, init_pool_size);
542 }
543
544 while (nr_add < init_populate) {
545 node = malloc(sizeof(struct cds_lfht_node));
546 cds_lfht_node_init(node,
547 (void *)(unsigned long)((rand_r(&rand_lookup) % init_pool_size) + init_pool_offset),
548 sizeof(void *));
549 if (add_unique)
550 ret_node = cds_lfht_add_unique(test_ht, node);
551 else
552 cds_lfht_add(test_ht, node);
553 if (add_unique && ret_node != node) {
554 free(node);
555 nr_addexist++;
556 } else
557 nr_add++;
558 nr_writes++;
559 }
560 return 0;
561 }
562
563 void show_usage(int argc, char **argv)
564 {
565 printf("Usage : %s nr_readers nr_writers duration (s)", argv[0]);
566 #ifdef DEBUG_YIELD
567 printf(" [-r] [-w] (yield reader and/or writer)");
568 #endif
569 printf(" [-d delay] (writer period (us))");
570 printf(" [-c duration] (reader C.S. duration (in loops))");
571 printf(" [-v] (verbose output)");
572 printf(" [-a cpu#] [-a cpu#]... (affinity)");
573 printf(" [-h size] (initial hash table size)");
574 printf(" [-u] Uniquify add.");
575 printf(" [-i] Add only (no removal).");
576 printf(" [-k nr_nodes] Number of nodes to insert initially.");
577 printf(" [-A] Automatically resize hash table.");
578 printf(" [-R offset] Lookup pool offset.");
579 printf(" [-S offset] Write pool offset.");
580 printf(" [-T offset] Init pool offset.");
581 printf(" [-M size] Lookup pool size.");
582 printf(" [-N size] Write pool size.");
583 printf(" [-O size] Init pool size.");
584 printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).");
585 printf("\n");
586 }
587
588 int main(int argc, char **argv)
589 {
590 int err;
591 pthread_t *tid_reader, *tid_writer;
592 void *tret;
593 unsigned long long *count_reader;
594 struct wr_count *count_writer;
595 unsigned long long tot_reads = 0, tot_writes = 0,
596 tot_add = 0, tot_add_exist = 0, tot_remove = 0;
597 unsigned long count, removed;
598 int i, a, ret;
599 struct sigaction act;
600 unsigned int remain;
601
602 if (argc < 4) {
603 show_usage(argc, argv);
604 return -1;
605 }
606
607 err = sscanf(argv[1], "%u", &nr_readers);
608 if (err != 1) {
609 show_usage(argc, argv);
610 return -1;
611 }
612
613 err = sscanf(argv[2], "%u", &nr_writers);
614 if (err != 1) {
615 show_usage(argc, argv);
616 return -1;
617 }
618
619 err = sscanf(argv[3], "%lu", &duration);
620 if (err != 1) {
621 show_usage(argc, argv);
622 return -1;
623 }
624
625 for (i = 4; i < argc; i++) {
626 if (argv[i][0] != '-')
627 continue;
628 switch (argv[i][1]) {
629 #ifdef DEBUG_YIELD
630 case 'r':
631 yield_active |= YIELD_READ;
632 break;
633 case 'w':
634 yield_active |= YIELD_WRITE;
635 break;
636 #endif
637 case 'a':
638 if (argc < i + 2) {
639 show_usage(argc, argv);
640 return -1;
641 }
642 a = atoi(argv[++i]);
643 cpu_affinities[next_aff++] = a;
644 use_affinity = 1;
645 printf_verbose("Adding CPU %d affinity\n", a);
646 break;
647 case 'c':
648 if (argc < i + 2) {
649 show_usage(argc, argv);
650 return -1;
651 }
652 rduration = atol(argv[++i]);
653 break;
654 case 'd':
655 if (argc < i + 2) {
656 show_usage(argc, argv);
657 return -1;
658 }
659 wdelay = atol(argv[++i]);
660 break;
661 case 'v':
662 verbose_mode = 1;
663 break;
664 case 'h':
665 if (argc < i + 2) {
666 show_usage(argc, argv);
667 return -1;
668 }
669 init_hash_size = atol(argv[++i]);
670 break;
671 case 'u':
672 add_unique = 1;
673 break;
674 case 'i':
675 add_only = 1;
676 break;
677 case 'k':
678 init_populate = atol(argv[++i]);
679 break;
680 case 'A':
681 opt_auto_resize = 1;
682 break;
683 case 'R':
684 lookup_pool_offset = atol(argv[++i]);
685 break;
686 case 'S':
687 write_pool_offset = atol(argv[++i]);
688 break;
689 case 'T':
690 init_pool_offset = atol(argv[++i]);
691 break;
692 case 'M':
693 lookup_pool_size = atol(argv[++i]);
694 break;
695 case 'N':
696 write_pool_size = atol(argv[++i]);
697 break;
698 case 'O':
699 init_pool_size = atol(argv[++i]);
700 break;
701 case 'V':
702 validate_lookup = 1;
703 break;
704
705 }
706 }
707
708 /* Check if hash size is power of 2 */
709 if (init_hash_size && init_hash_size & (init_hash_size - 1)) {
710 printf("Error: Hash table size %lu is not a power of 2.\n",
711 init_hash_size);
712 return -1;
713 }
714
715 memset(&act, 0, sizeof(act));
716 ret = sigemptyset(&act.sa_mask);
717 if (ret == -1) {
718 perror("sigemptyset");
719 return -1;
720 }
721 act.sa_handler = sigusr1_handler;
722 act.sa_flags = SA_RESTART;
723 ret = sigaction(SIGUSR1, &act, NULL);
724 if (ret == -1) {
725 perror("sigaction");
726 return -1;
727 }
728
729 printf_verbose("running test for %lu seconds, %u readers, %u writers.\n",
730 duration, nr_readers, nr_writers);
731 printf_verbose("Writer delay : %lu loops.\n", wdelay);
732 printf_verbose("Reader duration : %lu loops.\n", rduration);
733 printf_verbose("Mode:%s%s.\n",
734 add_only ? " add only" : " add/remove",
735 add_unique ? " uniquify" : "");
736 printf_verbose("Initial hash table size: %lu buckets.\n", init_hash_size);
737 printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
738 "main", pthread_self(), (unsigned long)gettid());
739
740 tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
741 tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
742 count_reader = malloc(sizeof(*count_reader) * nr_readers);
743 count_writer = malloc(sizeof(*count_writer) * nr_writers);
744 test_ht = cds_lfht_new(test_hash, test_compare, 0x42UL,
745 init_hash_size,
746 opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0,
747 call_rcu, synchronize_rcu, rcu_read_lock,
748 rcu_read_unlock, rcu_thread_offline,
749 rcu_thread_online);
750 ret = populate_hash();
751 assert(!ret);
752 err = create_all_cpu_call_rcu_data(0);
753 assert(!err);
754
755 next_aff = 0;
756
757 for (i = 0; i < nr_readers; i++) {
758 err = pthread_create(&tid_reader[i], NULL, thr_reader,
759 &count_reader[i]);
760 if (err != 0)
761 exit(1);
762 }
763 for (i = 0; i < nr_writers; i++) {
764 err = pthread_create(&tid_writer[i], NULL, thr_writer,
765 &count_writer[i]);
766 if (err != 0)
767 exit(1);
768 }
769
770 cmm_smp_mb();
771
772 test_go = 1;
773
774 remain = duration;
775 do {
776 remain = sleep(remain);
777 } while (remain > 0);
778
779 test_stop = 1;
780
781 for (i = 0; i < nr_readers; i++) {
782 err = pthread_join(tid_reader[i], &tret);
783 if (err != 0)
784 exit(1);
785 tot_reads += count_reader[i];
786 }
787 for (i = 0; i < nr_writers; i++) {
788 err = pthread_join(tid_writer[i], &tret);
789 if (err != 0)
790 exit(1);
791 tot_writes += count_writer[i].update_ops;
792 tot_add += count_writer[i].add;
793 tot_add_exist += count_writer[i].add_exist;
794 tot_remove += count_writer[i].remove;
795 }
796 printf("Counting nodes... ");
797 fflush(stdout);
798 cds_lfht_count_nodes(test_ht, &count, &removed);
799 printf("done.\n");
800 if (count || removed)
801 printf("WARNING: nodes left in the hash table upon destroy: "
802 "%lu nodes + %lu logically removed.\n", count, removed);
803 ret = cds_lfht_destroy(test_ht);
804
805 if (ret)
806 printf_verbose("final delete aborted\n");
807 else
808 printf_verbose("final delete success\n");
809 printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
810 tot_writes);
811 printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu "
812 "nr_writers %3u "
813 "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu "
814 "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n",
815 argv[0], duration, nr_readers, rduration,
816 nr_writers, wdelay, tot_reads, tot_writes,
817 tot_reads + tot_writes, tot_add, tot_add_exist, tot_remove,
818 (long long) tot_add + init_populate - tot_remove - count);
819 free_all_cpu_call_rcu_data();
820 free(tid_reader);
821 free(tid_writer);
822 free(count_reader);
823 free(count_writer);
824 return 0;
825 }
This page took 0.045388 seconds and 4 git commands to generate.