rculfhash tests: add uniqueness test
[urcu.git] / tests / test_urcu_hash.c
CommitLineData
ab7d5fc6 1/*
cd1ae16a 2 * test_urcu_hash.c
ab7d5fc6
MD
3 *
4 * Userspace RCU library - test program
5 *
18ca7a5b 6 * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
ab7d5fc6
MD
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
18ca7a5b 24#include "test_urcu_hash.h"
ab7d5fc6 25
f52c1ef7
MD
26enum test_hash {
27 TEST_HASH_RW,
20adf780 28 TEST_HASH_UNIQUE,
f52c1ef7
MD
29};
30
31struct test_hash_cb {
32 void (*sigusr1)(int signo);
33 void (*sigusr2)(int signo);
34 void *(*thr_reader)(void *_count);
35 void *(*thr_writer)(void *_count);
36 int (*populate_hash)(void);
37};
38
39static
40struct test_hash_cb test_hash_cb[] = {
41 [TEST_HASH_RW] = {
42 test_hash_rw_sigusr1_handler,
43 test_hash_rw_sigusr2_handler,
44 test_hash_rw_thr_reader,
45 test_hash_rw_thr_writer,
46 test_hash_rw_populate_hash,
47 },
20adf780
MD
48 [TEST_HASH_UNIQUE] = {
49 test_hash_unique_sigusr1_handler,
50 test_hash_unique_sigusr2_handler,
51 test_hash_unique_thr_reader,
52 test_hash_unique_thr_writer,
53 test_hash_unique_populate_hash,
54 },
55
f52c1ef7
MD
56};
57
58static enum test_hash test_choice = TEST_HASH_RW;
59
60void (*get_sigusr1_cb(void))(int)
61{
62 return test_hash_cb[test_choice].sigusr1;
63}
64
65void (*get_sigusr2_cb(void))(int)
66{
67 return test_hash_cb[test_choice].sigusr2;
68}
69
70void *(*get_thr_reader_cb(void))(void *)
71{
72 return test_hash_cb[test_choice].thr_reader;
73}
74
75void *(*get_thr_writer_cb(void))(void *)
76{
77 return test_hash_cb[test_choice].thr_writer;
78}
79
80int (*get_populate_hash_cb(void))(void)
81{
82 return test_hash_cb[test_choice].populate_hash;
83}
84
18ca7a5b
MD
85unsigned int __thread rand_lookup;
86unsigned long __thread nr_add;
87unsigned long __thread nr_addexist;
88unsigned long __thread nr_del;
89unsigned long __thread nr_delnoent;
90unsigned long __thread lookup_fail;
91unsigned long __thread lookup_ok;
b8e1907c 92
18ca7a5b 93struct cds_lfht *test_ht;
5e28c532 94
18ca7a5b 95volatile int test_go, test_stop;
ab7d5fc6 96
18ca7a5b 97unsigned long wdelay;
ab7d5fc6 98
18ca7a5b 99unsigned long duration;
ab7d5fc6
MD
100
101/* read-side C.S. duration, in loops */
18ca7a5b
MD
102unsigned long rduration;
103
104unsigned long init_hash_size = DEFAULT_HASH_SIZE;
105unsigned long min_hash_alloc_size = DEFAULT_MIN_ALLOC_SIZE;
106unsigned long max_hash_buckets_size = (1UL << 20);
107unsigned long init_populate;
108int opt_auto_resize;
109int add_only, add_unique, add_replace;
110const struct cds_lfht_mm_type *memory_backend;
111
112unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset;
113unsigned long init_pool_size = DEFAULT_RAND_POOL,
d837911d
MD
114 lookup_pool_size = DEFAULT_RAND_POOL,
115 write_pool_size = DEFAULT_RAND_POOL;
18ca7a5b 116int validate_lookup;
8008a032 117
18ca7a5b 118int count_pipe[2];
7ed7682f 119
18ca7a5b 120int verbose_mode;
ab7d5fc6 121
18ca7a5b
MD
122unsigned int cpu_affinities[NR_CPUS];
123unsigned int next_aff = 0;
124int use_affinity = 0;
ab7d5fc6 125
18ca7a5b 126pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
ab7d5fc6 127
18ca7a5b
MD
128unsigned long long __thread nr_writes;
129unsigned long long __thread nr_reads;
ab7d5fc6 130
18ca7a5b
MD
131unsigned int nr_readers;
132unsigned int nr_writers;
ab7d5fc6 133
18ca7a5b 134static pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER;
fb6d173d 135
18ca7a5b 136void set_affinity(void)
ab7d5fc6
MD
137{
138 cpu_set_t mask;
139 int cpu;
140 int ret;
141
142 if (!use_affinity)
143 return;
144
fb6d173d 145#if HAVE_SCHED_SETAFFINITY
ab7d5fc6
MD
146 ret = pthread_mutex_lock(&affinity_mutex);
147 if (ret) {
148 perror("Error in pthread mutex lock");
149 exit(-1);
150 }
151 cpu = cpu_affinities[next_aff++];
152 ret = pthread_mutex_unlock(&affinity_mutex);
153 if (ret) {
154 perror("Error in pthread mutex unlock");
155 exit(-1);
156 }
157 CPU_ZERO(&mask);
158 CPU_SET(cpu, &mask);
fb6d173d
MD
159#if SCHED_SETAFFINITY_ARGS == 2
160 sched_setaffinity(0, &mask);
161#else
162 sched_setaffinity(0, sizeof(mask), &mask);
163#endif
164#endif /* HAVE_SCHED_SETAFFINITY */
ab7d5fc6
MD
165}
166
ab7d5fc6
MD
167void rcu_copy_mutex_lock(void)
168{
169 int ret;
170 ret = pthread_mutex_lock(&rcu_copy_mutex);
171 if (ret) {
172 perror("Error in pthread mutex lock");
173 exit(-1);
174 }
175}
176
177void rcu_copy_mutex_unlock(void)
178{
179 int ret;
180
181 ret = pthread_mutex_unlock(&rcu_copy_mutex);
182 if (ret) {
183 perror("Error in pthread mutex unlock");
184 exit(-1);
185 }
186}
187
996ff57c
MD
188unsigned long test_compare(const void *key1, size_t key1_len,
189 const void *key2, size_t key2_len)
732ad076 190{
8ed51e04 191 if (caa_unlikely(key1_len != key2_len))
732ad076
MD
192 return -1;
193 assert(key1_len == sizeof(unsigned long));
194 if (key1 == key2)
195 return 0;
196 else
197 return 1;
abc490a1 198}
ab7d5fc6 199
7ed7682f
MD
200void *thr_count(void *arg)
201{
202 printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
203 "counter", pthread_self(), (unsigned long)gettid());
204
205 rcu_register_thread();
206
207 for (;;) {
caf3653d 208 unsigned long count;
d933dd0e 209 long approx_before, approx_after;
7ed7682f
MD
210 ssize_t len;
211 char buf[1];
212
213 rcu_thread_offline();
214 len = read(count_pipe[0], buf, 1);
215 rcu_thread_online();
8ed51e04 216 if (caa_unlikely(!test_duration_read()))
7ed7682f
MD
217 break;
218 if (len != 1)
219 continue;
220 /* Accounting */
221 printf("Counting nodes... ");
222 fflush(stdout);
223 rcu_read_lock();
caf3653d 224 cds_lfht_count_nodes(test_ht, &approx_before, &count,
7ed7682f
MD
225 &approx_after);
226 rcu_read_unlock();
227 printf("done.\n");
d933dd0e 228 printf("Approximation before node accounting: %ld nodes.\n",
7ed7682f
MD
229 approx_before);
230 printf("Accounting of nodes in the hash table: "
caf3653d
MD
231 "%lu nodes.\n",
232 count);
d933dd0e 233 printf("Approximation after node accounting: %ld nodes.\n",
7ed7682f
MD
234 approx_after);
235 }
236 rcu_unregister_thread();
237 return NULL;
238}
239
abc490a1
MD
240void free_node_cb(struct rcu_head *head)
241{
3c692076 242 struct lfht_test_node *node =
81d91005 243 caa_container_of(head, struct lfht_test_node, head);
abc490a1
MD
244 free(node);
245}
246
175ec0eb
MD
247static
248void test_delete_all_nodes(struct cds_lfht *ht)
249{
250 struct cds_lfht_iter iter;
3c692076 251 struct lfht_test_node *node;
175ec0eb
MD
252 unsigned long count = 0;
253
6d320126 254 cds_lfht_for_each_entry(ht, &iter, node, node) {
175ec0eb
MD
255 int ret;
256
bc8c3c74 257 ret = cds_lfht_del(test_ht, cds_lfht_iter_get_node(&iter));
175ec0eb 258 assert(!ret);
81d91005 259 call_rcu(&node->head, free_node_cb);
175ec0eb
MD
260 count++;
261 }
262 printf("deleted %lu nodes.\n", count);
263}
264
ab7d5fc6
MD
265void show_usage(int argc, char **argv)
266{
48ed1c18 267 printf("Usage : %s nr_readers nr_writers duration (s)\n", argv[0]);
ab7d5fc6 268#ifdef DEBUG_YIELD
48ed1c18 269 printf(" [-r] [-w] (yield reader and/or writer)\n");
ab7d5fc6 270#endif
48ed1c18
MD
271 printf(" [-d delay] (writer period (us))\n");
272 printf(" [-c duration] (reader C.S. duration (in loops))\n");
273 printf(" [-v] (verbose output)\n");
274 printf(" [-a cpu#] [-a cpu#]... (affinity)\n");
b99436d7
LJ
275 printf(" [-h size] (initial number of buckets)\n");
276 printf(" [-m size] (minimum number of allocated buckets)\n");
277 printf(" [-n size] (maximum number of buckets)\n");
18ca7a5b 278printf(" [not -u nor -s] Add entries (supports redundant keys).\n");
48ed1c18
MD
279 printf(" [-u] Uniquify add (no redundant keys).\n");
280 printf(" [-s] Replace (swap) entries.\n");
281 printf(" [-i] Add only (no removal).\n");
282 printf(" [-k nr_nodes] Number of nodes to insert initially.\n");
283 printf(" [-A] Automatically resize hash table.\n");
c0b8a865 284 printf(" [-B order|chunk|mmap] Specify the memory backend.\n");
48ed1c18
MD
285 printf(" [-R offset] Lookup pool offset.\n");
286 printf(" [-S offset] Write pool offset.\n");
287 printf(" [-T offset] Init pool offset.\n");
288 printf(" [-M size] Lookup pool size.\n");
289 printf(" [-N size] Write pool size.\n");
290 printf(" [-O size] Init pool size.\n");
291 printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).\n");
20adf780 292 printf(" [-U] Uniqueness test.\n");
48ed1c18 293 printf("\n\n");
ab7d5fc6
MD
294}
295
296int main(int argc, char **argv)
297{
298 int err;
299 pthread_t *tid_reader, *tid_writer;
7ed7682f 300 pthread_t tid_count;
ab7d5fc6 301 void *tret;
b8e1907c
MD
302 unsigned long long *count_reader;
303 struct wr_count *count_writer;
304 unsigned long long tot_reads = 0, tot_writes = 0,
3c16bf4b 305 tot_add = 0, tot_add_exist = 0, tot_remove = 0;
caf3653d 306 unsigned long count;
d933dd0e 307 long approx_before, approx_after;
5e28c532 308 int i, a, ret;
3967a8a8
MD
309 struct sigaction act;
310 unsigned int remain;
ab7d5fc6
MD
311
312 if (argc < 4) {
313 show_usage(argc, argv);
314 return -1;
315 }
316
317 err = sscanf(argv[1], "%u", &nr_readers);
318 if (err != 1) {
319 show_usage(argc, argv);
320 return -1;
321 }
322
323 err = sscanf(argv[2], "%u", &nr_writers);
324 if (err != 1) {
325 show_usage(argc, argv);
326 return -1;
327 }
328
329 err = sscanf(argv[3], "%lu", &duration);
330 if (err != 1) {
331 show_usage(argc, argv);
332 return -1;
333 }
334
335 for (i = 4; i < argc; i++) {
336 if (argv[i][0] != '-')
337 continue;
338 switch (argv[i][1]) {
339#ifdef DEBUG_YIELD
340 case 'r':
341 yield_active |= YIELD_READ;
342 break;
343 case 'w':
344 yield_active |= YIELD_WRITE;
345 break;
346#endif
347 case 'a':
348 if (argc < i + 2) {
349 show_usage(argc, argv);
350 return -1;
351 }
352 a = atoi(argv[++i]);
353 cpu_affinities[next_aff++] = a;
354 use_affinity = 1;
355 printf_verbose("Adding CPU %d affinity\n", a);
356 break;
357 case 'c':
358 if (argc < i + 2) {
359 show_usage(argc, argv);
360 return -1;
361 }
362 rduration = atol(argv[++i]);
363 break;
364 case 'd':
365 if (argc < i + 2) {
366 show_usage(argc, argv);
367 return -1;
368 }
369 wdelay = atol(argv[++i]);
370 break;
371 case 'v':
372 verbose_mode = 1;
373 break;
6d5c0ca9
MD
374 case 'h':
375 if (argc < i + 2) {
376 show_usage(argc, argv);
377 return -1;
378 }
379 init_hash_size = atol(argv[++i]);
380 break;
32becef6
LJ
381 case 'm':
382 if (argc < i + 2) {
383 show_usage(argc, argv);
384 return -1;
385 }
386 min_hash_alloc_size = atol(argv[++i]);
387 break;
b99436d7
LJ
388 case 'n':
389 if (argc < i + 2) {
390 show_usage(argc, argv);
391 return -1;
392 }
393 max_hash_buckets_size = atol(argv[++i]);
394 break;
6d5c0ca9 395 case 'u':
48ed1c18
MD
396 if (add_replace) {
397 printf("Please specify at most one of -s or -u.\n");
398 exit(-1);
399 }
6d5c0ca9
MD
400 add_unique = 1;
401 break;
48ed1c18
MD
402 case 's':
403 if (add_unique) {
404 printf("Please specify at most one of -s or -u.\n");
405 exit(-1);
406 }
407 add_replace = 1;
408 break;
6d5c0ca9
MD
409 case 'i':
410 add_only = 1;
411 break;
cd1ae16a
MD
412 case 'k':
413 init_populate = atol(argv[++i]);
414 break;
151e7a93
MD
415 case 'A':
416 opt_auto_resize = 1;
417 break;
c0b8a865
LJ
418 case 'B':
419 if (argc < i + 2) {
420 show_usage(argc, argv);
421 return -1;
422 }
423 i++;
424 if (!strcmp("order", argv[i]))
425 memory_backend = &cds_lfht_mm_order;
426 else if (!strcmp("chunk", argv[i]))
427 memory_backend = &cds_lfht_mm_chunk;
428 else if (!strcmp("mmap", argv[i]))
429 memory_backend = &cds_lfht_mm_mmap;
430 else {
431 printf("Please specify memory backend with order|chunk|mmap.\n");
432 exit(-1);
433 }
434 break;
8008a032
MD
435 case 'R':
436 lookup_pool_offset = atol(argv[++i]);
437 break;
438 case 'S':
439 write_pool_offset = atol(argv[++i]);
440 break;
441 case 'T':
442 init_pool_offset = atol(argv[++i]);
443 break;
d837911d
MD
444 case 'M':
445 lookup_pool_size = atol(argv[++i]);
446 break;
447 case 'N':
448 write_pool_size = atol(argv[++i]);
449 break;
450 case 'O':
451 init_pool_size = atol(argv[++i]);
452 break;
59b10634
MD
453 case 'V':
454 validate_lookup = 1;
455 break;
20adf780
MD
456 case 'U':
457 test_choice = TEST_HASH_UNIQUE;
458 break;
ab7d5fc6
MD
459 }
460 }
461
6d5c0ca9
MD
462 /* Check if hash size is power of 2 */
463 if (init_hash_size && init_hash_size & (init_hash_size - 1)) {
b99436d7 464 printf("Error: Initial number of buckets (%lu) is not a power of 2.\n",
6d5c0ca9
MD
465 init_hash_size);
466 return -1;
467 }
468
d0d8f9aa 469 if (min_hash_alloc_size && min_hash_alloc_size & (min_hash_alloc_size - 1)) {
b99436d7 470 printf("Error: Minimum number of allocated buckets (%lu) is not a power of 2.\n",
32becef6
LJ
471 min_hash_alloc_size);
472 return -1;
473 }
474
b99436d7
LJ
475 if (max_hash_buckets_size && max_hash_buckets_size & (max_hash_buckets_size - 1)) {
476 printf("Error: Maximum number of buckets (%lu) is not a power of 2.\n",
477 max_hash_buckets_size);
478 return -1;
479 }
480
3967a8a8
MD
481 memset(&act, 0, sizeof(act));
482 ret = sigemptyset(&act.sa_mask);
483 if (ret == -1) {
484 perror("sigemptyset");
485 return -1;
486 }
f52c1ef7 487 act.sa_handler = get_sigusr1_cb();
3967a8a8
MD
488 act.sa_flags = SA_RESTART;
489 ret = sigaction(SIGUSR1, &act, NULL);
490 if (ret == -1) {
491 perror("sigaction");
492 return -1;
493 }
7ed7682f
MD
494
495 ret = pipe(count_pipe);
496 if (ret == -1) {
497 perror("pipe");
498 return -1;
499 }
500
501 /* spawn counter thread */
502 err = pthread_create(&tid_count, NULL, thr_count,
503 NULL);
504 if (err != 0)
505 exit(1);
506
f52c1ef7 507 act.sa_handler = get_sigusr2_cb();
973e5e1b
MD
508 act.sa_flags = SA_RESTART;
509 ret = sigaction(SIGUSR2, &act, NULL);
510 if (ret == -1) {
511 perror("sigaction");
512 return -1;
513 }
3967a8a8 514
ab7d5fc6
MD
515 printf_verbose("running test for %lu seconds, %u readers, %u writers.\n",
516 duration, nr_readers, nr_writers);
517 printf_verbose("Writer delay : %lu loops.\n", wdelay);
518 printf_verbose("Reader duration : %lu loops.\n", rduration);
6d5c0ca9
MD
519 printf_verbose("Mode:%s%s.\n",
520 add_only ? " add only" : " add/remove",
48ed1c18 521 add_unique ? " uniquify" : ( add_replace ? " replace" : " insert"));
b99436d7
LJ
522 printf_verbose("Initial number of buckets: %lu buckets.\n", init_hash_size);
523 printf_verbose("Minimum number of allocated buckets: %lu buckets.\n", min_hash_alloc_size);
524 printf_verbose("Maximum number of buckets: %lu buckets.\n", max_hash_buckets_size);
5dc00396
MD
525 printf_verbose("Init pool size offset %lu size %lu.\n",
526 init_pool_offset, init_pool_size);
527 printf_verbose("Lookup pool size offset %lu size %lu.\n",
528 lookup_pool_offset, lookup_pool_size);
529 printf_verbose("Update pool size offset %lu size %lu.\n",
530 write_pool_offset, write_pool_size);
ab7d5fc6
MD
531 printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
532 "main", pthread_self(), (unsigned long)gettid());
533
ab7d5fc6
MD
534 tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
535 tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
536 count_reader = malloc(sizeof(*count_reader) * nr_readers);
537 count_writer = malloc(sizeof(*count_writer) * nr_writers);
48ed1c18
MD
538
539 err = create_all_cpu_call_rcu_data(0);
8bcbd94a
MD
540 if (err) {
541 printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n");
542 }
48ed1c18 543
c0b8a865
LJ
544 if (memory_backend) {
545 test_ht = _cds_lfht_new(init_hash_size, min_hash_alloc_size,
546 max_hash_buckets_size,
547 (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
548 CDS_LFHT_ACCOUNTING, memory_backend,
549 &rcu_flavor, NULL);
550 } else {
551 test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size,
552 max_hash_buckets_size,
553 (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
554 CDS_LFHT_ACCOUNTING, NULL);
555 }
556
48ed1c18 557 /*
c0b8a865 558 * Hash Population needs to be seen as a RCU reader
48ed1c18
MD
559 * thread from the point of view of resize.
560 */
561 rcu_register_thread();
f52c1ef7 562 ret = (get_populate_hash_cb())();
5dc45f25 563 assert(!ret);
59e371e3
MD
564
565 rcu_thread_offline();
14756542 566
ab7d5fc6
MD
567 next_aff = 0;
568
569 for (i = 0; i < nr_readers; i++) {
18ca7a5b 570 err = pthread_create(&tid_reader[i],
f52c1ef7 571 NULL, get_thr_reader_cb(),
ab7d5fc6
MD
572 &count_reader[i]);
573 if (err != 0)
574 exit(1);
575 }
576 for (i = 0; i < nr_writers; i++) {
18ca7a5b 577 err = pthread_create(&tid_writer[i],
f52c1ef7 578 NULL, get_thr_writer_cb(),
ab7d5fc6
MD
579 &count_writer[i]);
580 if (err != 0)
581 exit(1);
582 }
583
abc490a1 584 cmm_smp_mb();
ab7d5fc6
MD
585
586 test_go = 1;
587
3967a8a8
MD
588 remain = duration;
589 do {
590 remain = sleep(remain);
591 } while (remain > 0);
ab7d5fc6
MD
592
593 test_stop = 1;
594
595 for (i = 0; i < nr_readers; i++) {
596 err = pthread_join(tid_reader[i], &tret);
597 if (err != 0)
598 exit(1);
599 tot_reads += count_reader[i];
600 }
601 for (i = 0; i < nr_writers; i++) {
602 err = pthread_join(tid_writer[i], &tret);
603 if (err != 0)
604 exit(1);
b8e1907c
MD
605 tot_writes += count_writer[i].update_ops;
606 tot_add += count_writer[i].add;
3c16bf4b 607 tot_add_exist += count_writer[i].add_exist;
b8e1907c 608 tot_remove += count_writer[i].remove;
ab7d5fc6 609 }
7ed7682f
MD
610
611 /* teardown counter thread */
612 act.sa_handler = SIG_IGN;
613 act.sa_flags = SA_RESTART;
614 ret = sigaction(SIGUSR2, &act, NULL);
615 if (ret == -1) {
616 perror("sigaction");
617 return -1;
618 }
619 {
620 char msg[1] = { 0x42 };
3fb1173c
MD
621 ssize_t ret;
622
623 do {
624 ret = write(count_pipe[1], msg, 1); /* wakeup thread */
625 } while (ret == -1L && errno == EINTR);
7ed7682f
MD
626 }
627 err = pthread_join(tid_count, &tret);
628 if (err != 0)
629 exit(1);
630
33c7c748 631 fflush(stdout);
59e371e3
MD
632 rcu_thread_online();
633 rcu_read_lock();
175ec0eb 634 printf("Counting nodes... ");
caf3653d 635 cds_lfht_count_nodes(test_ht, &approx_before, &count, &approx_after);
175ec0eb
MD
636 printf("done.\n");
637 test_delete_all_nodes(test_ht);
59e371e3
MD
638 rcu_read_unlock();
639 rcu_thread_offline();
caf3653d 640 if (count) {
d933dd0e 641 printf("Approximation before node accounting: %ld nodes.\n",
973e5e1b 642 approx_before);
175ec0eb 643 printf("Nodes deleted from hash table before destroy: "
caf3653d
MD
644 "%lu nodes.\n",
645 count);
d933dd0e 646 printf("Approximation after node accounting: %ld nodes.\n",
973e5e1b
MD
647 approx_after);
648 }
b7d619b0 649 ret = cds_lfht_destroy(test_ht, NULL);
33c7c748
MD
650 if (ret)
651 printf_verbose("final delete aborted\n");
652 else
653 printf_verbose("final delete success\n");
ab7d5fc6
MD
654 printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
655 tot_writes);
656 printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu "
657 "nr_writers %3u "
d837911d 658 "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu "
cd1ae16a 659 "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n",
ab7d5fc6 660 argv[0], duration, nr_readers, rduration,
d837911d 661 nr_writers, wdelay, tot_reads, tot_writes,
3c16bf4b 662 tot_reads + tot_writes, tot_add, tot_add_exist, tot_remove,
cd1ae16a 663 (long long) tot_add + init_populate - tot_remove - count);
59e371e3 664 rcu_unregister_thread();
3a22f1dd 665 free_all_cpu_call_rcu_data();
ab7d5fc6
MD
666 free(tid_reader);
667 free(tid_writer);
668 free(count_reader);
669 free(count_writer);
670 return 0;
671}
This page took 0.063643 seconds and 4 git commands to generate.