[lttng-dev] urcu lfht and free listing
Mathieu Desnoyers
mathieu.desnoyers at efficios.com
Fri Jun 10 18:46:21 UTC 2016
----- On Jun 10, 2016, at 2:36 PM, D'Alessandro, Luke K ldalessa at indiana.edu wrote:
>> On Jun 10, 2016, at 2:22 PM, Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> wrote:
>>
>> ----- 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).
>
> Hi Mathieu,
>
> Thanks for the response.
>
> I did read that documentation but it only references “freeing” the memory which
> I read as “returning the memory to the allocator via free()” which can
> sometimes be an issue as it can cascade into an munmap that is concurrent with
> some reader. I wasn’t sure if simply reusing the memory was a problem.
Indeed, it could be clearer. I just updated the comments in the master branch.
commit 5002434419b458f1de889b3ed1110b440d3bf5b0
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Fri Jun 10 14:43:40 2016 -0400
rculfhash: Documentation: clarify need for grace period before "re-using"
Grace period must be waited for in case a node removed from the hash
table is re-used, similarly to the reclaim use-case.
Reported-by: Luke K D'Alessandro <ldalessa at indiana.edu>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Thanks!
Mathieu
>
>> 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).
>
> Great, thank you.
>
> Thanks,
>
> Luke
>
>>
>> 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
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list