[ltt-dev] liburcu-reclaim: Userspace RCU memory reclamation library

Mathieu Desnoyers mathieu.desnoyers at polymtl.ca
Sat Sep 19 18:22:13 EDT 2009


Hi !

I just coded an "automated memory reclamation" library based on RCU.

See commit 90075a50c3d4ab810f7d9ac218b53cda0ed67fe5 in the git tree.

The main idea behind this library is to add a layer on top of RCU
providing the following function to queue memory reclamation requests:

void rcu_reclaim_queue(void *p);

So after publishing a new object, instead of waiting with
synchronize_rcu() and explicitly freeing the object, just passing it to
rcu_reclaim_queue will free it for you whenever possible. It will be
freed either in a short while by a thread (created/joined by the
library), or by the thread performing the call to rcu_reclaim_queue() if
the queue is full.

Adding to the queue is wait-free if the queue is not full, but can block
if the queue is full.

This liburcu-reclaim.c library is brand new, so hopefully I did not do
too many gross mistakes. Note that I did a specialized library for
memory reclamation rather than a generic "call_rcu()" because I wanted
to have a simple array of pointers rather than tuples (function,
pointer) to ensure we use the minimum amount of cache. So it's currently
limited to "free()" calls. More flexibility might be welcome though, but
not at the expense of cache if possible. I'm trying to come up with a
cheap way to have per-callback queues.

The test_urcu_reclaim.c -> test_urcu_mb_reclaim is only implemented for
the "memory barrier" flavor of rcu, but liburcu-reclaim.so should work
fine with any of mb/signal/qsbr flavor of the urcu library too.

Git tree is at:

lttng.org:/home/git/userspace-rcu.git

Comments are welcome,

Mathieu

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.casi.polymtl.ca/pipermail/lttng-dev/attachments/20090919/a7989440/attachment-0003.pgp>


More information about the lttng-dev mailing list