static unsigned long min_hash_alloc_size = 1;
static unsigned long max_hash_buckets_size = 0;
+/*
+ * Getter/lookup functions need to be called with RCU read-side lock
+ * held. However, modification functions (add, add_unique, replace, del)
+ * take the RCU lock internally, so it does not matter whether the
+ * caller hold the RCU lock or not.
+ */
+
/*
* Match function for string node.
*/
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(node->key, lttng_ht_seed),
ht->match_fct, node->key, &node->node);
+ rcu_read_unlock();
assert(node_ptr == &node->node);
}
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
cds_lfht_add(ht->ht, ht->hash_fct(node->key, lttng_ht_seed),
&node->node);
+ rcu_read_unlock();
}
/*
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
cds_lfht_add(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed),
&node->node);
+ rcu_read_unlock();
}
/*
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
cds_lfht_add(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed),
&node->node);
+ rcu_read_unlock();
}
/*
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct,
(void *) node->key, &node->node);
+ rcu_read_unlock();
assert(node_ptr == &node->node);
}
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct,
&node->key, &node->node);
+ rcu_read_unlock();
assert(node_ptr == &node->node);
}
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct((void *) &node->key, lttng_ht_seed), ht->match_fct,
(void *) &node->key, &node->node);
+ rcu_read_unlock();
assert(node_ptr == &node->node);
}
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_replace(ht->ht,
ht->hash_fct((void *) node->key, lttng_ht_seed), ht->match_fct,
(void *) node->key, &node->node);
+ rcu_read_unlock();
if (!node_ptr) {
return NULL;
} else {
assert(ht->ht);
assert(node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
node_ptr = cds_lfht_add_replace(ht->ht,
ht->hash_fct(&node->key, lttng_ht_seed), ht->match_fct,
&node->key, &node->node);
+ rcu_read_unlock();
if (!node_ptr) {
return NULL;
} else {
*/
int lttng_ht_del(struct lttng_ht *ht, struct lttng_ht_iter *iter)
{
+ int ret;
+
assert(ht);
assert(ht->ht);
assert(iter);
- return cds_lfht_del(ht->ht, iter->iter.node);
+ /* RCU read lock protects from ABA. */
+ rcu_read_lock();
+ ret = cds_lfht_del(ht->ht, iter->iter.node);
+ rcu_read_unlock();
+ return ret;
}
/*
assert(ht);
assert(ht->ht);
+ /* RCU read lock protects from ABA and allows RCU traversal. */
+ rcu_read_lock();
cds_lfht_count_nodes(ht->ht, &scb, &count, &sca);
+ rcu_read_unlock();
return count;
}