Re: [RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

Mathieu Desnoyers <[email protected]> Wed, 7 Jan 2026 09:40:56 -0500
Newsgroups dev.linux.lists.lkmm
Message-ID <[email protected]>
On 2026-01-07 04:38, Jonas Oberhauser wrote:
> 
>> liburcu uatomics and "cmm_*" API initially aimed to replicate the LKMM in userspace (note: this was done circa 2009). However, starting from liburcu 0.15, we extended the uatomics API to support the C11 model
> 
> I expect the C11-style-semantics will have a lot of friction with RCU (at the least because of missing dependency ordering).

* RCU publication guarantee:

C11 has the "consume" MO (which we call CMM_CONSUME in liburcu) for the
dependency required by rcu_dereference. AFAIK it is implemented as the
stronger "acquire" MO on most toolchains today though. For those who
really want to keep using a volatile access for rcu_dereference in
liburcu for performance reasons, we introduced the
URCU_DEREFERENCE_USE_VOLATILE define in liburcu. This pairs with a C11
store-release on rcu_assign_pointer.

Note that the CONSUME MO with store-release pairing is required to
let threadsanitizer know about RCU publication guarantee ordering.

* RCU grace period guarantee:

For the read-side critical section (rcu_read_{lock,unlock}) pairing with
synchronize_rcu, we've updated the liburcu read lock/unlock
implementation to use either atomic thread fence as full barrier or
SEQ_CST stores. We've also introduced a urcu/annotate.h header to help
annotating memory access groups. This helps threadsanitizer track the
dependency ordering inherent to RCU grace periods.

> Things like rmb and wmb may also not have a clean formalization in a C11-style semantics.

Right. We've been moving away from cmm_smp_rmb() and cmm_smp_wmb() in
favor of explicit C11 acquire/release dependency chains within the
liburcu implementation as of liburcu 0.15. This facilitates integration
with tools like threadsanitizer. The rmb/wmb APIs are still there for
legacy reasons, but users are encouraged to move to a acquire/release
model when it makes sense.

Thanks,

Mathieu

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