- printf_verbose("thread %-6s, thread id : %lx, tid %lu\n",
- "main", pthread_self(), (unsigned long)gettid());
-
- tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
- tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
- count_reader = malloc(sizeof(*count_reader) * nr_readers);
- count_writer = malloc(sizeof(*count_writer) * nr_writers);
- test_ht = ht_new(test_hash, (void *) 0x42,
- HASH_SIZE, call_rcu);
+ printf_verbose("Mode:%s%s.\n",
+ add_only ? " add only" : " add/remove",
+ add_unique ? " uniquify" : ( add_replace ? " replace" : " insert"));
+ printf_verbose("Initial number of buckets: %lu buckets.\n", init_hash_size);
+ printf_verbose("Minimum number of allocated buckets: %lu buckets.\n", min_hash_alloc_size);
+ printf_verbose("Maximum number of buckets: %lu buckets.\n", max_hash_buckets_size);
+ printf_verbose("Init pool size offset %lu size %lu.\n",
+ init_pool_offset, init_pool_size);
+ printf_verbose("Lookup pool size offset %lu size %lu.\n",
+ lookup_pool_offset, lookup_pool_size);
+ printf_verbose("Update pool size offset %lu size %lu.\n",
+ write_pool_offset, write_pool_size);
+ printf_verbose("Number of hash chains: %lu.\n",
+ nr_hash_chains);
+ printf_verbose("thread %-6s, tid %lu\n",
+ "main", urcu_get_thread_id());
+
+ tid_reader = calloc(nr_readers, sizeof(*tid_reader));
+ if (!tid_reader) {
+ mainret = 1;
+ goto end;
+ }
+ tid_writer = calloc(nr_writers, sizeof(*tid_writer));
+ if (!tid_writer) {
+ mainret = 1;
+ goto end_free_tid_reader;
+ }
+ count_reader = calloc(nr_readers, sizeof(*count_reader));
+ if (!count_reader) {
+ mainret = 1;
+ goto end_free_tid_writer;
+ }
+ count_writer = calloc(nr_writers, sizeof(*count_writer));
+ if (!count_writer) {
+ mainret = 1;
+ goto end_free_count_reader;
+ }
+
+ err = create_all_cpu_call_rcu_data(0);
+ if (err) {
+ printf("Per-CPU call_rcu() worker threads unavailable. Using default global worker thread.\n");
+ }
+
+ if (memory_backend) {
+ test_ht = _cds_lfht_new(init_hash_size, min_hash_alloc_size,
+ max_hash_buckets_size,
+ (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
+ CDS_LFHT_ACCOUNTING, memory_backend,
+ &rcu_flavor, NULL);
+ } else {
+ test_ht = cds_lfht_new(init_hash_size, min_hash_alloc_size,
+ max_hash_buckets_size,
+ (opt_auto_resize ? CDS_LFHT_AUTO_RESIZE : 0) |
+ CDS_LFHT_ACCOUNTING, NULL);
+ }
+ if (!test_ht) {
+ printf("Error allocating hash table.\n");
+ mainret = 1;
+ goto end_free_call_rcu_data;
+ }
+
+ /*
+ * Hash Population needs to be seen as a RCU reader
+ * thread from the point of view of resize.
+ */
+ rcu_register_thread();
+ ret = (get_populate_hash_cb())();
+ assert(!ret);
+
+ rcu_thread_offline();
+