If I understand you correctly, you can do something like this:

#undef rcu_read_lock
#define rcu_read_lock() urcu_memb_read_lock(); {

#undef rcu_read_unlock
#define rcu_read_lock() } urcu_memb_read_unlock();

(replace memb with your RCU variant of course)

and make your code declare all the RCU protected pointers inside the RCU 
critical section, e.g.

rcu_read_lock();
my_pointer *foo = rcu_dereference(...);

use(foo); /* valid */

rcu_read_unlock();


use(foo); /* invalid and caught by the compiler */

Ondrej
--
Ondřej Surý (He/Him)
ond...@sury.org

> On 2. 9. 2025, at 23:06, Thobias Knudsen via lttng-dev 
> <lttng-dev@lists.lttng.org> wrote:
> 
> Yes, that is what I'm worried about. For my case when using URCU that is my 
> biggest concern, as the debug macro "library" I made checks everything else, 
> if I haven't overlooked anything.
> 

Reply via email to