Commit | Line | Data |
---|---|---|
ab7d5fc6 | 1 | /* |
cd1ae16a | 2 | * test_urcu_hash.c |
ab7d5fc6 MD |
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> | |
ab7d5fc6 | 33 | #include <sched.h> |
5e28c532 | 34 | #include <errno.h> |
ab7d5fc6 | 35 | |
abc490a1 MD |
36 | #ifdef __linux__ |
37 | #include <syscall.h> | |
38 | #endif | |
ab7d5fc6 | 39 | |
6d5c0ca9 | 40 | #define DEFAULT_HASH_SIZE 32 |
32becef6 | 41 | #define DEFAULT_MIN_ALLOC_SIZE 1 |
6d5c0ca9 | 42 | #define DEFAULT_RAND_POOL 1000000 |
5e28c532 | 43 | |
0422d92c MD |
44 | #define TEST_HASH_SEED 0x42UL |
45 | ||
ab7d5fc6 MD |
46 | /* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ |
47 | #define CACHE_LINE_SIZE 4096 | |
48 | ||
49 | /* hardcoded number of CPUs */ | |
50 | #define NR_CPUS 16384 | |
51 | ||
98808fb1 MD |
52 | #ifdef POISON_FREE |
53 | #define poison_free(ptr) \ | |
54 | do { \ | |
55 | memset(ptr, 0x42, sizeof(*(ptr))); \ | |
56 | free(ptr); \ | |
57 | } while (0) | |
58 | #else | |
59 | #define poison_free(ptr) free(ptr) | |
60 | #endif | |
61 | ||
62 | ||
63 | ||
ab7d5fc6 MD |
64 | #if defined(_syscall0) |
65 | _syscall0(pid_t, gettid) | |
66 | #elif defined(__NR_gettid) | |
67 | static inline pid_t gettid(void) | |
68 | { | |
69 | return syscall(__NR_gettid); | |
70 | } | |
71 | #else | |
72 | #warning "use pid as tid" | |
73 | static inline pid_t gettid(void) | |
74 | { | |
75 | return getpid(); | |
76 | } | |
77 | #endif | |
78 | ||
79 | #ifndef DYNAMIC_LINK_TEST | |
80 | #define _LGPL_SOURCE | |
81 | #else | |
82 | #define debug_yield_read() | |
83 | #endif | |
5567839e | 84 | #include <urcu-qsbr.h> |
abc490a1 MD |
85 | #include <urcu/rculfhash.h> |
86 | #include <urcu-call-rcu.h> | |
ab7d5fc6 | 87 | |
b8e1907c MD |
88 | struct wr_count { |
89 | unsigned long update_ops; | |
90 | unsigned long add; | |
3c16bf4b | 91 | unsigned long add_exist; |
b8e1907c MD |
92 | unsigned long remove; |
93 | }; | |
94 | ||
5e28c532 MD |
95 | static unsigned int __thread rand_lookup; |
96 | static unsigned long __thread nr_add; | |
97 | static unsigned long __thread nr_addexist; | |
98 | static unsigned long __thread nr_del; | |
99 | static unsigned long __thread nr_delnoent; | |
100 | static unsigned long __thread lookup_fail; | |
101 | static unsigned long __thread lookup_ok; | |
102 | ||
14044b37 | 103 | static struct cds_lfht *test_ht; |
ab7d5fc6 | 104 | |
5e28c532 | 105 | struct test_data { |
ab7d5fc6 | 106 | int a; |
5e28c532 | 107 | int b; |
ab7d5fc6 MD |
108 | }; |
109 | ||
3c692076 LJ |
110 | struct lfht_test_node { |
111 | struct cds_lfht_node node; | |
04db56f8 LJ |
112 | void *key; |
113 | unsigned int key_len; | |
81d91005 LJ |
114 | /* cache-cold for iteration */ |
115 | struct rcu_head head; | |
3c692076 LJ |
116 | }; |
117 | ||
118 | static inline struct lfht_test_node * | |
119 | to_test_node(struct cds_lfht_node *node) | |
120 | { | |
121 | return caa_container_of(node, struct lfht_test_node, node); | |
122 | } | |
123 | ||
124 | static inline | |
125 | void lfht_test_node_init(struct lfht_test_node *node, void *key, | |
126 | size_t key_len) | |
127 | { | |
04db56f8 LJ |
128 | cds_lfht_node_init(&node->node); |
129 | node->key = key; | |
130 | node->key_len = key_len; | |
3c692076 LJ |
131 | } |
132 | ||
133 | static inline struct lfht_test_node * | |
134 | cds_lfht_iter_get_test_node(struct cds_lfht_iter *iter) | |
135 | { | |
136 | return to_test_node(cds_lfht_iter_get_node(iter)); | |
137 | } | |
138 | ||
ab7d5fc6 MD |
139 | static volatile int test_go, test_stop; |
140 | ||
141 | static unsigned long wdelay; | |
142 | ||
ab7d5fc6 MD |
143 | static unsigned long duration; |
144 | ||
145 | /* read-side C.S. duration, in loops */ | |
146 | static unsigned long rduration; | |
147 | ||
6d5c0ca9 | 148 | static unsigned long init_hash_size = DEFAULT_HASH_SIZE; |
32becef6 | 149 | static unsigned long min_hash_alloc_size = DEFAULT_MIN_ALLOC_SIZE; |
cd1ae16a | 150 | static unsigned long init_populate; |
151e7a93 | 151 | static int opt_auto_resize; |
48ed1c18 | 152 | static int add_only, add_unique, add_replace; |
6d5c0ca9 | 153 | |
8008a032 | 154 | static unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset; |
d837911d MD |
155 | static unsigned long init_pool_size = DEFAULT_RAND_POOL, |
156 | lookup_pool_size = DEFAULT_RAND_POOL, | |
157 | write_pool_size = DEFAULT_RAND_POOL; | |
59b10634 | 158 | static int validate_lookup; |
8008a032 | 159 | |
7ed7682f MD |
160 | static int count_pipe[2]; |
161 | ||
ab7d5fc6 MD |
162 | static inline void loop_sleep(unsigned long l) |
163 | { | |
164 | while(l-- != 0) | |
abc490a1 | 165 | caa_cpu_relax(); |
ab7d5fc6 MD |
166 | } |
167 | ||
168 | static int verbose_mode; | |
169 | ||
170 | #define printf_verbose(fmt, args...) \ | |
171 | do { \ | |
172 | if (verbose_mode) \ | |
33c7c748 | 173 | printf(fmt, ## args); \ |
ab7d5fc6 MD |
174 | } while (0) |
175 | ||
176 | static unsigned int cpu_affinities[NR_CPUS]; | |
177 | static unsigned int next_aff = 0; | |
178 | static int use_affinity = 0; | |
179 | ||
180 | pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; | |
181 | ||
182 | static void set_affinity(void) | |
183 | { | |
184 | cpu_set_t mask; | |
185 | int cpu; | |
186 | int ret; | |
187 | ||
188 | if (!use_affinity) | |
189 | return; | |
190 | ||
191 | ret = pthread_mutex_lock(&affinity_mutex); | |
192 | if (ret) { | |
193 | perror("Error in pthread mutex lock"); | |
194 | exit(-1); | |
195 | } | |
196 | cpu = cpu_affinities[next_aff++]; | |
197 | ret = pthread_mutex_unlock(&affinity_mutex); | |
198 | if (ret) { | |
199 | perror("Error in pthread mutex unlock"); | |
200 | exit(-1); | |
201 | } | |
202 | CPU_ZERO(&mask); | |
203 | CPU_SET(cpu, &mask); | |
204 | sched_setaffinity(0, sizeof(mask), &mask); | |
205 | } | |
206 | ||
3967a8a8 MD |
207 | static enum { |
208 | AR_RANDOM = 0, | |
209 | AR_ADD = 1, | |
210 | AR_REMOVE = -1, | |
211 | } addremove; /* 1: add, -1 remove, 0: random */ | |
212 | ||
213 | static | |
214 | void sigusr1_handler(int signo) | |
215 | { | |
216 | switch (addremove) { | |
217 | case AR_ADD: | |
218 | printf("Add/Remove: random.\n"); | |
219 | addremove = AR_RANDOM; | |
220 | break; | |
221 | case AR_RANDOM: | |
222 | printf("Add/Remove: remove only.\n"); | |
223 | addremove = AR_REMOVE; | |
224 | break; | |
225 | case AR_REMOVE: | |
226 | printf("Add/Remove: add only.\n"); | |
227 | addremove = AR_ADD; | |
228 | break; | |
229 | } | |
230 | } | |
231 | ||
973e5e1b MD |
232 | static |
233 | void sigusr2_handler(int signo) | |
234 | { | |
7ed7682f | 235 | char msg[1] = { 0x42 }; |
3fb1173c MD |
236 | ssize_t ret; |
237 | ||
238 | do { | |
239 | ret = write(count_pipe[1], msg, 1); /* wakeup thread */ | |
240 | } while (ret == -1L && errno == EINTR); | |
973e5e1b MD |
241 | } |
242 | ||
ab7d5fc6 MD |
243 | /* |
244 | * returns 0 if test should end. | |
245 | */ | |
246 | static int test_duration_write(void) | |
247 | { | |
248 | return !test_stop; | |
249 | } | |
250 | ||
251 | static int test_duration_read(void) | |
252 | { | |
253 | return !test_stop; | |
254 | } | |
255 | ||
256 | static unsigned long long __thread nr_writes; | |
257 | static unsigned long long __thread nr_reads; | |
258 | ||
259 | static unsigned int nr_readers; | |
260 | static unsigned int nr_writers; | |
261 | ||
262 | pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; | |
263 | ||
264 | void rcu_copy_mutex_lock(void) | |
265 | { | |
266 | int ret; | |
267 | ret = pthread_mutex_lock(&rcu_copy_mutex); | |
268 | if (ret) { | |
269 | perror("Error in pthread mutex lock"); | |
270 | exit(-1); | |
271 | } | |
272 | } | |
273 | ||
274 | void rcu_copy_mutex_unlock(void) | |
275 | { | |
276 | int ret; | |
277 | ||
278 | ret = pthread_mutex_unlock(&rcu_copy_mutex); | |
279 | if (ret) { | |
280 | perror("Error in pthread mutex unlock"); | |
281 | exit(-1); | |
282 | } | |
283 | } | |
284 | ||
732ad076 MD |
285 | /* |
286 | * Hash function | |
287 | * Source: http://burtleburtle.net/bob/c/lookup3.c | |
288 | * Originally Public Domain | |
289 | */ | |
290 | ||
291 | #define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k)))) | |
292 | ||
293 | #define mix(a, b, c) \ | |
294 | do { \ | |
295 | a -= c; a ^= rot(c, 4); c += b; \ | |
296 | b -= a; b ^= rot(a, 6); a += c; \ | |
297 | c -= b; c ^= rot(b, 8); b += a; \ | |
298 | a -= c; a ^= rot(c, 16); c += b; \ | |
299 | b -= a; b ^= rot(a, 19); a += c; \ | |
300 | c -= b; c ^= rot(b, 4); b += a; \ | |
301 | } while (0) | |
302 | ||
303 | #define final(a, b, c) \ | |
304 | { \ | |
305 | c ^= b; c -= rot(b, 14); \ | |
306 | a ^= c; a -= rot(c, 11); \ | |
307 | b ^= a; b -= rot(a, 25); \ | |
308 | c ^= b; c -= rot(b, 16); \ | |
309 | a ^= c; a -= rot(c, 4);\ | |
310 | b ^= a; b -= rot(a, 14); \ | |
311 | c ^= b; c -= rot(b, 24); \ | |
312 | } | |
313 | ||
314 | static __attribute__((unused)) | |
315 | uint32_t hash_u32( | |
316 | const uint32_t *k, /* the key, an array of uint32_t values */ | |
317 | size_t length, /* the length of the key, in uint32_ts */ | |
318 | uint32_t initval) /* the previous hash, or an arbitrary value */ | |
319 | { | |
320 | uint32_t a, b, c; | |
321 | ||
322 | /* Set up the internal state */ | |
323 | a = b = c = 0xdeadbeef + (((uint32_t) length) << 2) + initval; | |
324 | ||
325 | /*----------------------------------------- handle most of the key */ | |
326 | while (length > 3) { | |
327 | a += k[0]; | |
328 | b += k[1]; | |
329 | c += k[2]; | |
330 | mix(a, b, c); | |
331 | length -= 3; | |
332 | k += 3; | |
333 | } | |
334 | ||
335 | /*----------------------------------- handle the last 3 uint32_t's */ | |
336 | switch (length) { /* all the case statements fall through */ | |
337 | case 3: c += k[2]; | |
338 | case 2: b += k[1]; | |
339 | case 1: a += k[0]; | |
340 | final(a, b, c); | |
341 | case 0: /* case 0: nothing left to add */ | |
342 | break; | |
343 | } | |
344 | /*---------------------------------------------- report the result */ | |
345 | return c; | |
346 | } | |
347 | ||
348 | static | |
349 | void hashword2( | |
350 | const uint32_t *k, /* the key, an array of uint32_t values */ | |
351 | size_t length, /* the length of the key, in uint32_ts */ | |
352 | uint32_t *pc, /* IN: seed OUT: primary hash value */ | |
353 | uint32_t *pb) /* IN: more seed OUT: secondary hash value */ | |
354 | { | |
355 | uint32_t a, b, c; | |
356 | ||
357 | /* Set up the internal state */ | |
358 | a = b = c = 0xdeadbeef + ((uint32_t) (length << 2)) + *pc; | |
359 | c += *pb; | |
360 | ||
361 | /*----------------------------------------- handle most of the key */ | |
362 | while (length > 3) { | |
363 | a += k[0]; | |
364 | b += k[1]; | |
365 | c += k[2]; | |
366 | mix(a, b, c); | |
367 | length -= 3; | |
368 | k += 3; | |
369 | } | |
370 | ||
371 | /*----------------------------------- handle the last 3 uint32_t's */ | |
372 | switch (length) { /* all the case statements fall through */ | |
373 | case 3: c += k[2]; | |
374 | case 2: b += k[1]; | |
375 | case 1: a += k[0]; | |
376 | final(a, b, c); | |
377 | case 0: /* case 0: nothing left to add */ | |
378 | break; | |
379 | } | |
380 | /*---------------------------------------------- report the result */ | |
381 | *pc = c; | |
382 | *pb = b; | |
383 | } | |
384 | ||
385 | #if (CAA_BITS_PER_LONG == 32) | |
abc490a1 | 386 | static |
732ad076 | 387 | unsigned long test_hash(void *_key, size_t length, unsigned long seed) |
abc490a1 | 388 | { |
f542a7ee | 389 | unsigned int key = (unsigned int) _key; |
abc490a1 | 390 | |
f542a7ee | 391 | assert(length == sizeof(unsigned int)); |
bda21126 | 392 | return hash_u32(&key, 1, seed); |
732ad076 MD |
393 | } |
394 | #else | |
395 | static | |
396 | unsigned long test_hash(void *_key, size_t length, unsigned long seed) | |
397 | { | |
398 | union { | |
399 | uint64_t v64; | |
400 | uint32_t v32[2]; | |
401 | } v; | |
402 | union { | |
403 | uint64_t v64; | |
404 | uint32_t v32[2]; | |
405 | } key; | |
406 | ||
407 | assert(length == sizeof(unsigned long)); | |
408 | v.v64 = (uint64_t) seed; | |
409 | key.v64 = (uint64_t) _key; | |
410 | hashword2(key.v32, 2, &v.v32[0], &v.v32[1]); | |
411 | return v.v64; | |
412 | } | |
413 | #endif | |
abc490a1 | 414 | |
732ad076 MD |
415 | static |
416 | unsigned long test_compare(void *key1, size_t key1_len, | |
417 | void *key2, size_t key2_len) | |
418 | { | |
8ed51e04 | 419 | if (caa_unlikely(key1_len != key2_len)) |
732ad076 MD |
420 | return -1; |
421 | assert(key1_len == sizeof(unsigned long)); | |
422 | if (key1 == key2) | |
423 | return 0; | |
424 | else | |
425 | return 1; | |
abc490a1 | 426 | } |
ab7d5fc6 | 427 | |
0422d92c | 428 | static |
04db56f8 | 429 | int test_match(struct cds_lfht_node *node, void *key) |
0422d92c | 430 | { |
04db56f8 LJ |
431 | struct lfht_test_node *test_node = to_test_node(node); |
432 | ||
433 | return !test_compare(test_node->key, test_node->key_len, | |
434 | key, sizeof(unsigned long)); | |
0422d92c MD |
435 | } |
436 | ||
437 | static | |
438 | void cds_lfht_test_lookup(struct cds_lfht *ht, void *key, size_t key_len, | |
439 | struct cds_lfht_iter *iter) | |
440 | { | |
441 | assert(key_len == sizeof(unsigned long)); | |
442 | ||
443 | cds_lfht_lookup(ht, test_match, | |
444 | test_hash(key, key_len, TEST_HASH_SEED), | |
445 | key, iter); | |
446 | } | |
447 | ||
7ed7682f MD |
448 | void *thr_count(void *arg) |
449 | { | |
450 | printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", | |
451 | "counter", pthread_self(), (unsigned long)gettid()); | |
452 | ||
453 | rcu_register_thread(); | |
454 | ||
455 | for (;;) { | |
d933dd0e MD |
456 | unsigned long count, removed; |
457 | long approx_before, approx_after; | |
7ed7682f MD |
458 | ssize_t len; |
459 | char buf[1]; | |
460 | ||
461 | rcu_thread_offline(); | |
462 | len = read(count_pipe[0], buf, 1); | |
463 | rcu_thread_online(); | |
8ed51e04 | 464 | if (caa_unlikely(!test_duration_read())) |
7ed7682f MD |
465 | break; |
466 | if (len != 1) | |
467 | continue; | |
468 | /* Accounting */ | |
469 | printf("Counting nodes... "); | |
470 | fflush(stdout); | |
471 | rcu_read_lock(); | |
472 | cds_lfht_count_nodes(test_ht, &approx_before, &count, &removed, | |
473 | &approx_after); | |
474 | rcu_read_unlock(); | |
475 | printf("done.\n"); | |
d933dd0e | 476 | printf("Approximation before node accounting: %ld nodes.\n", |
7ed7682f MD |
477 | approx_before); |
478 | printf("Accounting of nodes in the hash table: " | |
479 | "%lu nodes + %lu logically removed.\n", | |
480 | count, removed); | |
d933dd0e | 481 | printf("Approximation after node accounting: %ld nodes.\n", |
7ed7682f MD |
482 | approx_after); |
483 | } | |
484 | rcu_unregister_thread(); | |
485 | return NULL; | |
486 | } | |
487 | ||
ab7d5fc6 MD |
488 | void *thr_reader(void *_count) |
489 | { | |
490 | unsigned long long *count = _count; | |
3c692076 | 491 | struct lfht_test_node *node; |
adc0de68 | 492 | struct cds_lfht_iter iter; |
ab7d5fc6 MD |
493 | |
494 | printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", | |
495 | "reader", pthread_self(), (unsigned long)gettid()); | |
496 | ||
497 | set_affinity(); | |
498 | ||
499 | rcu_register_thread(); | |
500 | ||
501 | while (!test_go) | |
502 | { | |
503 | } | |
abc490a1 | 504 | cmm_smp_mb(); |
ab7d5fc6 MD |
505 | |
506 | for (;;) { | |
507 | rcu_read_lock(); | |
0422d92c | 508 | cds_lfht_test_lookup(test_ht, |
c8f5b384 | 509 | (void *)(((unsigned long) rand_r(&rand_lookup) % lookup_pool_size) + lookup_pool_offset), |
adc0de68 | 510 | sizeof(void *), &iter); |
3c692076 | 511 | node = cds_lfht_iter_get_test_node(&iter); |
59b10634 MD |
512 | if (node == NULL) { |
513 | if (validate_lookup) { | |
514 | printf("[ERROR] Lookup cannot find initial node.\n"); | |
46834ba6 | 515 | exit(-1); |
59b10634 | 516 | } |
5e28c532 | 517 | lookup_fail++; |
59b10634 | 518 | } else { |
5e28c532 | 519 | lookup_ok++; |
59b10634 | 520 | } |
ab7d5fc6 | 521 | debug_yield_read(); |
8ed51e04 | 522 | if (caa_unlikely(rduration)) |
ab7d5fc6 MD |
523 | loop_sleep(rduration); |
524 | rcu_read_unlock(); | |
525 | nr_reads++; | |
8ed51e04 | 526 | if (caa_unlikely(!test_duration_read())) |
ab7d5fc6 | 527 | break; |
8ed51e04 | 528 | if (caa_unlikely((nr_reads & ((1 << 10) - 1)) == 0)) |
5567839e | 529 | rcu_quiescent_state(); |
ab7d5fc6 MD |
530 | } |
531 | ||
532 | rcu_unregister_thread(); | |
533 | ||
534 | *count = nr_reads; | |
535 | printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", | |
536 | "reader", pthread_self(), (unsigned long)gettid()); | |
5e28c532 MD |
537 | printf_verbose("readid : %lx, lookupfail %lu, lookupok %lu\n", |
538 | pthread_self(), lookup_fail, lookup_ok); | |
ab7d5fc6 MD |
539 | return ((void*)1); |
540 | ||
541 | } | |
542 | ||
abc490a1 MD |
543 | static |
544 | void free_node_cb(struct rcu_head *head) | |
545 | { | |
3c692076 | 546 | struct lfht_test_node *node = |
81d91005 | 547 | caa_container_of(head, struct lfht_test_node, head); |
abc490a1 MD |
548 | free(node); |
549 | } | |
550 | ||
ab7d5fc6 MD |
551 | void *thr_writer(void *_count) |
552 | { | |
3c692076 LJ |
553 | struct lfht_test_node *node; |
554 | struct cds_lfht_node *ret_node; | |
adc0de68 | 555 | struct cds_lfht_iter iter; |
b8e1907c | 556 | struct wr_count *count = _count; |
5e28c532 | 557 | int ret; |
ab7d5fc6 MD |
558 | |
559 | printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n", | |
560 | "writer", pthread_self(), (unsigned long)gettid()); | |
561 | ||
562 | set_affinity(); | |
563 | ||
5e28c532 | 564 | rcu_register_thread(); |
5e28c532 | 565 | |
ab7d5fc6 MD |
566 | while (!test_go) |
567 | { | |
568 | } | |
abc490a1 | 569 | cmm_smp_mb(); |
ab7d5fc6 MD |
570 | |
571 | for (;;) { | |
3967a8a8 MD |
572 | if ((addremove == AR_ADD || add_only) |
573 | || (addremove == AR_RANDOM && rand_r(&rand_lookup) & 1)) { | |
3c692076 LJ |
574 | node = malloc(sizeof(struct lfht_test_node)); |
575 | lfht_test_node_init(node, | |
c8f5b384 | 576 | (void *)(((unsigned long) rand_r(&rand_lookup) % write_pool_size) + write_pool_offset), |
cb233752 | 577 | sizeof(void *)); |
6b262fd7 | 578 | rcu_read_lock(); |
48ed1c18 | 579 | if (add_unique) { |
04db56f8 LJ |
580 | ret_node = cds_lfht_add_unique(test_ht, test_match, node->key, |
581 | test_hash(node->key, node->key_len, TEST_HASH_SEED), | |
0422d92c | 582 | &node->node); |
48ed1c18 MD |
583 | } else { |
584 | if (add_replace) | |
04db56f8 LJ |
585 | ret_node = cds_lfht_add_replace(test_ht, test_match, node->key, |
586 | test_hash(node->key, node->key_len, TEST_HASH_SEED), | |
0422d92c | 587 | &node->node); |
48ed1c18 | 588 | else |
0422d92c | 589 | cds_lfht_add(test_ht, |
04db56f8 | 590 | test_hash(node->key, node->key_len, TEST_HASH_SEED), |
0422d92c | 591 | &node->node); |
48ed1c18 | 592 | } |
abc490a1 | 593 | rcu_read_unlock(); |
3c692076 | 594 | if (add_unique && ret_node != &node->node) { |
742aa1db | 595 | free(node); |
3eca1b8c | 596 | nr_addexist++; |
48ed1c18 MD |
597 | } else { |
598 | if (add_replace && ret_node) { | |
81d91005 | 599 | call_rcu(&to_test_node(ret_node)->head, |
3c692076 | 600 | free_node_cb); |
48ed1c18 MD |
601 | nr_addexist++; |
602 | } else { | |
603 | nr_add++; | |
604 | } | |
605 | } | |
5e28c532 MD |
606 | } else { |
607 | /* May delete */ | |
abc490a1 | 608 | rcu_read_lock(); |
0422d92c | 609 | cds_lfht_test_lookup(test_ht, |
c8f5b384 | 610 | (void *)(((unsigned long) rand_r(&rand_lookup) % write_pool_size) + write_pool_offset), |
adc0de68 | 611 | sizeof(void *), &iter); |
9357c415 | 612 | ret = cds_lfht_del(test_ht, &iter); |
abc490a1 MD |
613 | rcu_read_unlock(); |
614 | if (ret == 0) { | |
3c692076 | 615 | node = cds_lfht_iter_get_test_node(&iter); |
81d91005 | 616 | call_rcu(&node->head, free_node_cb); |
5e28c532 | 617 | nr_del++; |
abc490a1 MD |
618 | } else |
619 | nr_delnoent++; | |
44395fb7 | 620 | } |
abc490a1 | 621 | #if 0 |
44395fb7 MD |
622 | //if (nr_writes % 100000 == 0) { |
623 | if (nr_writes % 1000 == 0) { | |
abc490a1 | 624 | rcu_read_lock(); |
44395fb7 MD |
625 | if (rand_r(&rand_lookup) & 1) { |
626 | ht_resize(test_ht, 1); | |
627 | } else { | |
628 | ht_resize(test_ht, -1); | |
629 | } | |
abc490a1 | 630 | rcu_read_unlock(); |
5e28c532 | 631 | } |
abc490a1 | 632 | #endif //0 |
ab7d5fc6 | 633 | nr_writes++; |
8ed51e04 | 634 | if (caa_unlikely(!test_duration_write())) |
ab7d5fc6 | 635 | break; |
8ed51e04 | 636 | if (caa_unlikely(wdelay)) |
ab7d5fc6 | 637 | loop_sleep(wdelay); |
8ed51e04 | 638 | if (caa_unlikely((nr_writes & ((1 << 10) - 1)) == 0)) |
5567839e | 639 | rcu_quiescent_state(); |
ab7d5fc6 MD |
640 | } |
641 | ||
5e28c532 MD |
642 | rcu_unregister_thread(); |
643 | ||
ab7d5fc6 MD |
644 | printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", |
645 | "writer", pthread_self(), (unsigned long)gettid()); | |
5e28c532 MD |
646 | printf_verbose("info id %lx: nr_add %lu, nr_addexist %lu, nr_del %lu, " |
647 | "nr_delnoent %lu\n", pthread_self(), nr_add, | |
648 | nr_addexist, nr_del, nr_delnoent); | |
b8e1907c MD |
649 | count->update_ops = nr_writes; |
650 | count->add = nr_add; | |
3c16bf4b | 651 | count->add_exist = nr_addexist; |
b8e1907c | 652 | count->remove = nr_del; |
ab7d5fc6 MD |
653 | return ((void*)2); |
654 | } | |
655 | ||
5dc45f25 | 656 | static int populate_hash(void) |
cd1ae16a | 657 | { |
3c692076 LJ |
658 | struct lfht_test_node *node; |
659 | struct cds_lfht_node *ret_node; | |
cd1ae16a MD |
660 | |
661 | if (!init_populate) | |
5dc45f25 MD |
662 | return 0; |
663 | ||
48ed1c18 | 664 | if ((add_unique || add_replace) && init_populate * 10 > init_pool_size) { |
5dc45f25 | 665 | printf("WARNING: required to populate %lu nodes (-k), but random " |
48ed1c18 | 666 | "pool is quite small (%lu values) and we are in add_unique (-u) or add_replace (-s) mode. Try with a " |
d837911d | 667 | "larger random pool (-p option). This may take a while...\n", init_populate, init_pool_size); |
5dc45f25 | 668 | } |
cd1ae16a MD |
669 | |
670 | while (nr_add < init_populate) { | |
3c692076 LJ |
671 | node = malloc(sizeof(struct lfht_test_node)); |
672 | lfht_test_node_init(node, | |
c8f5b384 | 673 | (void *)(((unsigned long) rand_r(&rand_lookup) % init_pool_size) + init_pool_offset), |
cd1ae16a | 674 | sizeof(void *)); |
48ed1c18 MD |
675 | rcu_read_lock(); |
676 | if (add_unique) { | |
04db56f8 LJ |
677 | ret_node = cds_lfht_add_unique(test_ht, test_match, node->key, |
678 | test_hash(node->key, node->key_len, TEST_HASH_SEED), | |
0422d92c | 679 | &node->node); |
48ed1c18 MD |
680 | } else { |
681 | if (add_replace) | |
04db56f8 LJ |
682 | ret_node = cds_lfht_add_replace(test_ht, test_match, node->key, |
683 | test_hash(node->key, node->key_len, TEST_HASH_SEED), | |
0422d92c | 684 | &node->node); |
48ed1c18 | 685 | else |
0422d92c | 686 | cds_lfht_add(test_ht, |
04db56f8 | 687 | test_hash(node->key, node->key_len, TEST_HASH_SEED), |
0422d92c | 688 | &node->node); |
48ed1c18 MD |
689 | } |
690 | rcu_read_unlock(); | |
3c692076 | 691 | if (add_unique && ret_node != &node->node) { |
cd1ae16a MD |
692 | free(node); |
693 | nr_addexist++; | |
48ed1c18 MD |
694 | } else { |
695 | if (add_replace && ret_node) { | |
81d91005 | 696 | call_rcu(&to_test_node(ret_node)->head, free_node_cb); |
48ed1c18 MD |
697 | nr_addexist++; |
698 | } else { | |
699 | nr_add++; | |
700 | } | |
701 | } | |
cd1ae16a MD |
702 | nr_writes++; |
703 | } | |
5dc45f25 | 704 | return 0; |
cd1ae16a MD |
705 | } |
706 | ||
175ec0eb MD |
707 | static |
708 | void test_delete_all_nodes(struct cds_lfht *ht) | |
709 | { | |
710 | struct cds_lfht_iter iter; | |
3c692076 | 711 | struct lfht_test_node *node; |
175ec0eb MD |
712 | unsigned long count = 0; |
713 | ||
6d320126 | 714 | cds_lfht_for_each_entry(ht, &iter, node, node) { |
175ec0eb MD |
715 | int ret; |
716 | ||
717 | ret = cds_lfht_del(test_ht, &iter); | |
718 | assert(!ret); | |
81d91005 | 719 | call_rcu(&node->head, free_node_cb); |
175ec0eb MD |
720 | count++; |
721 | } | |
722 | printf("deleted %lu nodes.\n", count); | |
723 | } | |
724 | ||
ab7d5fc6 MD |
725 | void show_usage(int argc, char **argv) |
726 | { | |
48ed1c18 | 727 | printf("Usage : %s nr_readers nr_writers duration (s)\n", argv[0]); |
ab7d5fc6 | 728 | #ifdef DEBUG_YIELD |
48ed1c18 | 729 | printf(" [-r] [-w] (yield reader and/or writer)\n"); |
ab7d5fc6 | 730 | #endif |
48ed1c18 MD |
731 | printf(" [-d delay] (writer period (us))\n"); |
732 | printf(" [-c duration] (reader C.S. duration (in loops))\n"); | |
733 | printf(" [-v] (verbose output)\n"); | |
734 | printf(" [-a cpu#] [-a cpu#]... (affinity)\n"); | |
735 | printf(" [-h size] (initial hash table size)\n"); | |
32becef6 | 736 | printf(" [-m size] (minimum hash alloc size)\n"); |
48ed1c18 MD |
737 | printf(" [not -u nor -s] Add entries (supports redundant keys).\n"); |
738 | printf(" [-u] Uniquify add (no redundant keys).\n"); | |
739 | printf(" [-s] Replace (swap) entries.\n"); | |
740 | printf(" [-i] Add only (no removal).\n"); | |
741 | printf(" [-k nr_nodes] Number of nodes to insert initially.\n"); | |
742 | printf(" [-A] Automatically resize hash table.\n"); | |
743 | printf(" [-R offset] Lookup pool offset.\n"); | |
744 | printf(" [-S offset] Write pool offset.\n"); | |
745 | printf(" [-T offset] Init pool offset.\n"); | |
746 | printf(" [-M size] Lookup pool size.\n"); | |
747 | printf(" [-N size] Write pool size.\n"); | |
748 | printf(" [-O size] Init pool size.\n"); | |
749 | printf(" [-V] Validate lookups of init values (use with filled init pool, same lookup range, with different write range).\n"); | |
750 | printf("\n\n"); | |
ab7d5fc6 MD |
751 | } |
752 | ||
753 | int main(int argc, char **argv) | |
754 | { | |
755 | int err; | |
756 | pthread_t *tid_reader, *tid_writer; | |
7ed7682f | 757 | pthread_t tid_count; |
ab7d5fc6 | 758 | void *tret; |
b8e1907c MD |
759 | unsigned long long *count_reader; |
760 | struct wr_count *count_writer; | |
761 | unsigned long long tot_reads = 0, tot_writes = 0, | |
3c16bf4b | 762 | tot_add = 0, tot_add_exist = 0, tot_remove = 0; |
d933dd0e MD |
763 | unsigned long count, removed; |
764 | long approx_before, approx_after; | |
5e28c532 | 765 | int i, a, ret; |
3967a8a8 MD |
766 | struct sigaction act; |
767 | unsigned int remain; | |
ab7d5fc6 MD |
768 | |
769 | if (argc < 4) { | |
770 | show_usage(argc, argv); | |
771 | return -1; | |
772 | } | |
773 | ||
774 | err = sscanf(argv[1], "%u", &nr_readers); | |
775 | if (err != 1) { | |
776 | show_usage(argc, argv); | |
777 | return -1; | |
778 | } | |
779 | ||
780 | err = sscanf(argv[2], "%u", &nr_writers); | |
781 | if (err != 1) { | |
782 | show_usage(argc, argv); | |
783 | return -1; | |
784 | } | |
785 | ||
786 | err = sscanf(argv[3], "%lu", &duration); | |
787 | if (err != 1) { | |
788 | show_usage(argc, argv); | |
789 | return -1; | |
790 | } | |
791 | ||
792 | for (i = 4; i < argc; i++) { | |
793 | if (argv[i][0] != '-') | |
794 | continue; | |
795 | switch (argv[i][1]) { | |
796 | #ifdef DEBUG_YIELD | |
797 | case 'r': | |
798 | yield_active |= YIELD_READ; | |
799 | break; | |
800 | case 'w': | |
801 | yield_active |= YIELD_WRITE; | |
802 | break; | |
803 | #endif | |
804 | case 'a': | |
805 | if (argc < i + 2) { | |
806 | show_usage(argc, argv); | |
807 | return -1; | |
808 | } | |
809 | a = atoi(argv[++i]); | |
810 | cpu_affinities[next_aff++] = a; | |
811 | use_affinity = 1; | |
812 | printf_verbose("Adding CPU %d affinity\n", a); | |
813 | break; | |
814 | case 'c': | |
815 | if (argc < i + 2) { | |
816 | show_usage(argc, argv); | |
817 | return -1; | |
818 | } | |
819 | rduration = atol(argv[++i]); | |
820 | break; | |
821 | case 'd': | |
822 | if (argc < i + 2) { | |
823 | show_usage(argc, argv); | |
824 | return -1; | |
825 | } | |
826 | wdelay = atol(argv[++i]); | |
827 | break; | |
828 | case 'v': | |
829 | verbose_mode = 1; | |
830 | break; | |
6d5c0ca9 MD |
831 | case 'h': |
832 | if (argc < i + 2) { | |
833 | show_usage(argc, argv); | |
834 | return -1; | |
835 | } | |
836 | init_hash_size = atol(argv[++i]); | |
837 | break; | |
32becef6 LJ |
838 | case 'm': |
839 | if (argc < i + 2) { | |
840 | show_usage(argc, argv); | |
841 | return -1; | |
842 | } | |
843 | min_hash_alloc_size = atol(argv[++i]); | |
844 | break; | |
6d5c0ca9 | 845 | case 'u': |
48ed1c18 MD |
846 | if (add_replace) { |
847 | printf("Please specify at most one of -s or -u.\n"); | |
848 | exit(-1); | |
849 | } | |
6d5c0ca9 MD |
850 | add_unique = 1; |
851 | break; | |
48ed1c18 MD |
852 | case 's': |
853 | if (add_unique) { | |
854 | printf("Please specify at most one of -s or -u.\n"); | |
855 | exit(-1); | |
856 | } | |
857 | add_replace = 1; | |
858 | break; | |
6d5c0ca9 MD |
859 | case 'i': |
860 | add_only = 1; | |
861 | break; | |
cd1ae16a MD |
862 | case 'k': |
863 | init_populate = atol(argv[++i]); | |
864 | break; | |
151e7a93 MD |
865 | case 'A': |
866 | opt_auto_resize = 1; | |
867 | break; | |
8008a032 MD |
868 | case 'R': |
869 | lookup_pool_offset = atol(argv[++i]); | |
870 | break; | |
871 | case 'S': | |
872 | write_pool_offset = atol(argv[++i]); | |
873 | break; | |
874 | case 'T': | |
875 | init_pool_offset = atol(argv[++i]); | |
876 | break; | |
d837911d MD |
877 | case 'M': |
878 | lookup_pool_size = atol(argv[++i]); | |
879 | break; | |
880 | case 'N': | |
881 | write_pool_size = atol(argv[++i]); | |
882 | break; | |
883 | case 'O': | |
884 | init_pool_size = atol(argv[++i]); | |
885 | break; | |
59b10634 MD |
886 | case 'V': |
887 | validate_lookup = 1; | |
888 | break; | |
8008a032 | 889 | |
ab7d5fc6 MD |
890 | } |
891 | } | |
892 | ||
6d5c0ca9 MD |
893 | /* Check if hash size is power of 2 */ |
894 | if (init_hash_size && init_hash_size & (init_hash_size - 1)) { | |
895 | printf("Error: Hash table size %lu is not a power of 2.\n", | |
896 | init_hash_size); | |
897 | return -1; | |
898 | } | |
899 | ||
32becef6 LJ |
900 | if (min_hash_alloc_size && min_hash_alloc_size * (min_hash_alloc_size - 1)) { |
901 | printf("Error: Min hash alloc size %lu is not a power of 2.\n", | |
902 | min_hash_alloc_size); | |
903 | return -1; | |
904 | } | |
905 | ||
3967a8a8 MD |
906 | memset(&act, 0, sizeof(act)); |
907 | ret = sigemptyset(&act.sa_mask); | |
908 | if (ret == -1) { | |
909 | perror("sigemptyset"); | |
910 | return -1; | |
911 | } | |
912 | act.sa_handler = sigusr1_handler; | |
913 | act.sa_flags = SA_RESTART; | |
914 | ret = sigaction(SIGUSR1, &act, NULL); | |
915 | if (ret == -1) { | |
916 | perror("sigaction"); | |
917 | return -1; | |
918 | } | |
7ed7682f MD |
919 | |
920 | ret = pipe(count_pipe); | |
921 | if (ret == -1) { | |
922 | perror("pipe"); | |
923 | return -1; | |
924 | } | |
925 | ||
926 | /* spawn counter thread */ | |
927 | err = pthread_create(&tid_count, NULL, thr_count, | |
928 | NULL); | |
929 | if (err != 0) | |
930 | exit(1); | |
931 | ||
973e5e1b MD |
932 | act.sa_handler = sigusr2_handler; |
933 | act.sa_flags = SA_RESTART; | |
934 | ret = sigaction(SIGUSR2, &act, NULL); | |
935 | if (ret == -1) { | |
936 | perror("sigaction"); | |
937 | return -1; | |
938 | } | |
3967a8a8 | 939 | |
ab7d5fc6 MD |
940 | printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", |
941 | duration, nr_readers, nr_writers); | |
942 | printf_verbose("Writer delay : %lu loops.\n", wdelay); | |
943 | printf_verbose("Reader duration : %lu loops.\n", rduration); | |
6d5c0ca9 MD |
944 | printf_verbose("Mode:%s%s.\n", |
945 | add_only ? " add only" : " add/remove", | |
48ed1c18 | 946 | add_unique ? " uniquify" : ( add_replace ? " replace" : " insert")); |
6d5c0ca9 | 947 | printf_verbose("Initial hash table size: %lu buckets.\n", init_hash_size); |
32becef6 | 948 | printf_verbose("Minimum hash alloc size: %lu buckets.\n", min_hash_alloc_size); |
5dc00396 MD |
949 | printf_verbose("Init pool size offset %lu size %lu.\n", |
950 | init_pool_offset, init_pool_size); | |
951 | printf_verbose("Lookup pool size offset %lu size %lu.\n", | |
952 | lookup_pool_offset, lookup_pool_size); | |
953 | printf_verbose("Update pool size offset %lu size %lu.\n", | |
954 | write_pool_offset, write_pool_size); | |
ab7d5fc6 MD |
955 | printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", |
956 | "main", pthread_self(), (unsigned long)gettid()); | |
957 | ||
ab7d5fc6 MD |
958 | tid_reader = malloc(sizeof(*tid_reader) * nr_readers); |
959 | tid_writer = malloc(sizeof(*tid_writer) * nr_writers); | |
960 | count_reader = malloc(sizeof(*count_reader) * nr_readers); | |
961 | count_writer = malloc(sizeof(*count_writer) * nr_writers); | |
48ed1c18 MD |
962 | |
963 | err = create_all_cpu_call_rcu_data(0); | |
964 | assert(!err); | |
965 | ||
966 | /* | |
967 | * Hash creation and population needs to be seen as a RCU reader | |
968 | * thread from the point of view of resize. | |
969 | */ | |
970 | rcu_register_thread(); | |
0422d92c | 971 | test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size, |
5afadd12 LJ |
972 | (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) | |
973 | CDS_LFHT_ACCOUNTING, NULL); | |
48ed1c18 | 974 | ret = populate_hash(); |
5dc45f25 | 975 | assert(!ret); |
59e371e3 MD |
976 | |
977 | rcu_thread_offline(); | |
14756542 | 978 | |
ab7d5fc6 MD |
979 | next_aff = 0; |
980 | ||
981 | for (i = 0; i < nr_readers; i++) { | |
982 | err = pthread_create(&tid_reader[i], NULL, thr_reader, | |
983 | &count_reader[i]); | |
984 | if (err != 0) | |
985 | exit(1); | |
986 | } | |
987 | for (i = 0; i < nr_writers; i++) { | |
988 | err = pthread_create(&tid_writer[i], NULL, thr_writer, | |
989 | &count_writer[i]); | |
990 | if (err != 0) | |
991 | exit(1); | |
992 | } | |
993 | ||
abc490a1 | 994 | cmm_smp_mb(); |
ab7d5fc6 MD |
995 | |
996 | test_go = 1; | |
997 | ||
3967a8a8 MD |
998 | remain = duration; |
999 | do { | |
1000 | remain = sleep(remain); | |
1001 | } while (remain > 0); | |
ab7d5fc6 MD |
1002 | |
1003 | test_stop = 1; | |
1004 | ||
1005 | for (i = 0; i < nr_readers; i++) { | |
1006 | err = pthread_join(tid_reader[i], &tret); | |
1007 | if (err != 0) | |
1008 | exit(1); | |
1009 | tot_reads += count_reader[i]; | |
1010 | } | |
1011 | for (i = 0; i < nr_writers; i++) { | |
1012 | err = pthread_join(tid_writer[i], &tret); | |
1013 | if (err != 0) | |
1014 | exit(1); | |
b8e1907c MD |
1015 | tot_writes += count_writer[i].update_ops; |
1016 | tot_add += count_writer[i].add; | |
3c16bf4b | 1017 | tot_add_exist += count_writer[i].add_exist; |
b8e1907c | 1018 | tot_remove += count_writer[i].remove; |
ab7d5fc6 | 1019 | } |
7ed7682f MD |
1020 | |
1021 | /* teardown counter thread */ | |
1022 | act.sa_handler = SIG_IGN; | |
1023 | act.sa_flags = SA_RESTART; | |
1024 | ret = sigaction(SIGUSR2, &act, NULL); | |
1025 | if (ret == -1) { | |
1026 | perror("sigaction"); | |
1027 | return -1; | |
1028 | } | |
1029 | { | |
1030 | char msg[1] = { 0x42 }; | |
3fb1173c MD |
1031 | ssize_t ret; |
1032 | ||
1033 | do { | |
1034 | ret = write(count_pipe[1], msg, 1); /* wakeup thread */ | |
1035 | } while (ret == -1L && errno == EINTR); | |
7ed7682f MD |
1036 | } |
1037 | err = pthread_join(tid_count, &tret); | |
1038 | if (err != 0) | |
1039 | exit(1); | |
1040 | ||
33c7c748 | 1041 | fflush(stdout); |
59e371e3 MD |
1042 | rcu_thread_online(); |
1043 | rcu_read_lock(); | |
175ec0eb | 1044 | printf("Counting nodes... "); |
973e5e1b MD |
1045 | cds_lfht_count_nodes(test_ht, &approx_before, &count, &removed, |
1046 | &approx_after); | |
175ec0eb MD |
1047 | printf("done.\n"); |
1048 | test_delete_all_nodes(test_ht); | |
59e371e3 MD |
1049 | rcu_read_unlock(); |
1050 | rcu_thread_offline(); | |
973e5e1b | 1051 | if (count || removed) { |
d933dd0e | 1052 | printf("Approximation before node accounting: %ld nodes.\n", |
973e5e1b | 1053 | approx_before); |
175ec0eb | 1054 | printf("Nodes deleted from hash table before destroy: " |
973e5e1b MD |
1055 | "%lu nodes + %lu logically removed.\n", |
1056 | count, removed); | |
d933dd0e | 1057 | printf("Approximation after node accounting: %ld nodes.\n", |
973e5e1b MD |
1058 | approx_after); |
1059 | } | |
b7d619b0 | 1060 | ret = cds_lfht_destroy(test_ht, NULL); |
33c7c748 MD |
1061 | if (ret) |
1062 | printf_verbose("final delete aborted\n"); | |
1063 | else | |
1064 | printf_verbose("final delete success\n"); | |
ab7d5fc6 MD |
1065 | printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads, |
1066 | tot_writes); | |
1067 | printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " | |
1068 | "nr_writers %3u " | |
d837911d | 1069 | "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu " |
cd1ae16a | 1070 | "nr_add %12llu nr_add_fail %12llu nr_remove %12llu nr_leaked %12lld\n", |
ab7d5fc6 | 1071 | argv[0], duration, nr_readers, rduration, |
d837911d | 1072 | nr_writers, wdelay, tot_reads, tot_writes, |
3c16bf4b | 1073 | tot_reads + tot_writes, tot_add, tot_add_exist, tot_remove, |
cd1ae16a | 1074 | (long long) tot_add + init_populate - tot_remove - count); |
59e371e3 | 1075 | rcu_unregister_thread(); |
3a22f1dd | 1076 | free_all_cpu_call_rcu_data(); |
ab7d5fc6 MD |
1077 | free(tid_reader); |
1078 | free(tid_writer); | |
1079 | free(count_reader); | |
1080 | free(count_writer); | |
1081 | return 0; | |
1082 | } |