[lttng-dev] urcu lfht and free listing

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Fri Jun 10 18:22:16 UTC 2016


----- On Jun 10, 2016, at 6:58 AM, D'Alessandro, Luke K ldalessa at indiana.edu wrote:

> Hi List,
> 
> Is it safe to free list and reuse hash table nodes (cds_lfht_node structures
> used in cds_lfht_add_replace, cds_lfht_iter_get_node/cds_lfht_del) without
> going through a synchronize_rcu() barrier?

Hi,

No, it is not safe.

>From rculfhash.h:

cds_lfht_del:

 * After successful removal, a grace period must be waited for before
 * freeing the memory reserved for old node (which can be accessed with
 * cds_lfht_iter_get_node).

cds_lfht_add_replace:

 * After successful replacement, a grace period must be waited for before
 * freeing the memory reserved for the returned node.

cds_lfht_replace:

 * After successful replacement, a grace period must be waited for before
 * freeing the memory reserved for the old node (which can be accessed
 * with cds_lfht_iter_get_node).

You can either invoke synchronize_rcu() before re-using or freeing
the removed node, or use the call_rcu() or defer_rcu() mechanisms to
defer reclaim after a grace period (handled by worker threads).

Thanks,

Mathieu

> 
> Thanks,
> Luke
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list