From: Mathieu Desnoyers Date: Sun, 8 Feb 2009 22:10:22 +0000 (-0500) Subject: Change API X-Git-Tag: v0.1~317 X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=c265818b951224bcde407b1efa14f9daf44949b3;hp=c265818b951224bcde407b1efa14f9daf44949b3;p=urcu.git Change API * rcu_read_lock > A patch below to allow nested rcu_read_lock() while keeping to the Linux > kernel API, just FYI. One can argue that the overhead of accessing the > extra per-thread variables is offset by the fact that there no longer > needs to be a return value from rcu_read_lock() nor an argument to > rcu_read_unlock(), but hard to say. > I ran your modified version within my benchmarks : with return value : 14.164 cycles per read without return value : 16.4017 cycles per read So we have a 14% performance decrease due to this. We also pollute the branch prediction buffer and we add a cache access due to the added variables in the TLS. Returning the value has the clear advantage of letting the compiler keep it around in registers or on the stack, which clearly costs less. So I think the speed factor outweights the visual considerations. Maybe we could switch to something like : unsigned int qparity; urcu_read_lock(&qparity); ... urcu_read_unlock(&qparity); That would be a bit like local_irq_save() in the kernel, except that we could do it in a static inline because we pass the address. I personnally dislike the local_irq_save() way of hiding the fact that it writes to the variable in a "clever" macro. I'd really prefer to leave the " & ". * rcu_write_lock Removed. Signed-off-by: Mathieu Desnoyers ---