Re: URCU feature request?

Thobias Knudsen via lttng-dev <[email protected]> Tue, 2 Sep 2025 23:48:43 +0200
Newsgroups org.lttng.lists.lttng-dev
Message-ID <CAKGpcip6w2nVQ+vbtfFH1296xTi5HYX+68J8okecChsihejDQA@mail.gmail.com>
--0000000000005eda15063dd87442
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Yes but all read/write operations doesn't have the syntax of a function as
you used in the example here i.e. use(...). When it is a function you can
easily just change the implementation to check if it is called inside a
read section. Some reads and writes are usually done by this syntax (a =3D =
b)
and '=3D' cannot be overridden.

BTW just saying that what we're talking about now is not the original
topic, but if someone has an elegant solution to this that would be nice!

Thanks
Thobias

tir. 2. sep. 2025 kl. 23:34 skrev Ond=C5=99ej Sur=C3=BD <[email protected]>:

> 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 =3D rcu_dereference(...);
>
> use(foo); /* valid */
>
> rcu_read_unlock();
>
>
> use(foo); /* invalid and caught by the compiler */
>
> Ondrej
> --
> Ond=C5=99ej Sur=C3=BD (He/Him)
> [email protected]
>
> > On 2. 9. 2025, at 23:06, Thobias Knudsen via lttng-dev <
> [email protected]> wrote:
> >
> > Yes, that is what I'm worried about. For my case when using URCU that i=
s
> my biggest concern, as the debug macro "library" I made checks everything
> else, if I haven't overlooked anything.
> >
>
>

--0000000000005eda15063dd87442
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yes but all read/write operations doesn&#39;t=C2=A0have th=
e syntax of a function as you used in the example here i.e. use(...). When =
it is a function you can easily just change the implementation to check if =
it is called inside a read section. Some reads and writes are usually done =
by this syntax (a =3D b) and &#39;=3D&#39; cannot be overridden.<div><br></=
div><div>BTW just saying that what we&#39;re talking about now is not the o=
riginal topic, but if someone has an elegant solution to this that would be=
 nice!<br><div><br></div><div>Thanks</div><div>Thobias</div></div></div><br=
><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D=
"gmail_attr">tir. 2. sep. 2025 kl. 23:34 skrev Ond=C5=99ej Sur=C3=BD &lt;<a=
 href=3D"mailto:[email protected]">[email protected]</a>&gt;:<br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px=
 solid rgb(204,204,204);padding-left:1ex">If I understand you correctly, yo=
u can do something like this:<br>
<br>
#undef rcu_read_lock<br>
#define rcu_read_lock() urcu_memb_read_lock(); {<br>
<br>
#undef rcu_read_unlock<br>
#define rcu_read_lock() } urcu_memb_read_unlock();<br>
<br>
(replace memb with your RCU variant of course)<br>
<br>
and make your code declare all the RCU protected pointers inside the RCU cr=
itical section, e.g.<br>
<br>
rcu_read_lock();<br>
my_pointer *foo =3D rcu_dereference(...);<br>
<br>
use(foo); /* valid */<br>
<br>
rcu_read_unlock();<br>
<br>
<br>
use(foo); /* invalid and caught by the compiler */<br>
<br>
Ondrej<br>
--<br>
Ond=C5=99ej Sur=C3=BD (He/Him)<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a><br=
>
<br>
&gt; On 2. 9. 2025, at 23:06, Thobias Knudsen via lttng-dev &lt;<a href=3D"=
mailto:[email protected]" target=3D"_blank">[email protected]=
rg</a>&gt; wrote:<br>
&gt; <br>
&gt; Yes, that is what I&#39;m worried about. For my case when using URCU t=
hat is my biggest concern, as the debug macro &quot;library&quot; I made ch=
ecks everything else, if I haven&#39;t overlooked anything.<br>
&gt; <br>
<br>
</blockquote></div>

--0000000000005eda15063dd87442--