Re: URCU feature request?

Thobias Knudsen via lttng-dev <[email protected]> Tue, 2 Sep 2025 16:24:16 +0200
Newsgroups org.lttng.lists.lttng-dev
Message-ID <CAKGpcipfyp3Ds4J0OH96Mu4zVhCLJg8g6tqEnfcRscZ1T8EmVA@mail.gmail.com>
--000000000000e68e4f063dd23eda
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Figured out what rcu_read_ongoing does. It just returns true if it's called
within a read section and false otherwise. The problem for catching whether
reads are done outside read sections is that you can not make macros for
read and write operations. e.g. ptr->a =3D 4;.

tir. 2. sep. 2025 kl. 16:17 skrev Thobias Knudsen <[email protected]>:

> > I suspect that what you are trying to achieve is validation that
> > calls to functions that require to be within a RCU read-side critical
> > section such as cds_lfht_lookup are indeed invoked from within a
> > critical section.
>
> Yes exactly, but not only for read sections. It could also be to validate
> that rcu_barrier isnt called within a callback function or that
> rcu_quiescent_state isnt called when thread is offline
>
> > We've added a "rcu_read_ongoing()" API for that purpose to liburcu
> > RCU flavors, but AFAIK it's not used for any kind of validation
> > within cds_lfht. This could indeed become a feature request that
> > would apply to all liburcu data structure APIs.
>
> I can't find any documentation on rcu_read_ongoing. Btw the documentation
> for urcu in general is scattered all around the repo it seems. It should
> have been all at one place imo. Should I make a feature request for it? I
> don't know how stuff works inside this repo though.
>
>
>
> man. 1. sep. 2025 kl. 17:09 skrev Mathieu Desnoyers <
> [email protected]>:
>
>> On 2025-08-31 16:48, Thobias Knudsen wrote:
>> > BTW i've made a macro library which overrides the
>> > urcu and lfht functions. It checks that you call the functions in the
>> > correct order. This has been really useful for debugging and I think i=
t
>> > would be useful to have it integrated into urcu to make the it more
>> user
>> > friendly. you could have it integrated with the macro DEBUG_RCU or mak=
e
>> > a new one, maybe DEBUG_FUNCTION_CALL_ORDER. The only thing it doesn't
>> > catch is if you continue to use data from cds_lfht_lookup() after
>> > rcu_read_unlock()
>>
>> I suspect that what you are trying to achieve is validation that
>> calls to functions that require to be within a RCU read-side critical
>> section such as cds_lfht_lookup are indeed invoked from within a
>> critical section.
>>
>> We've added a "rcu_read_ongoing()" API for that purpose to liburcu
>> RCU flavors, but AFAIK it's not used for any kind of validation
>> within cds_lfht. This could indeed become a feature request that
>> would apply to all liburcu data structure APIs.
>>
>> Thanks,
>>
>> Mathieu
>>
>> >
>> > s=C3=B8n. 31. aug. 2025 kl. 22:42 skrev Thobias Knudsen <thobknu@gmail=
.com
>> > <mailto:[email protected]>>:
>> >
>> >     First question: why isn't Userspace RCU more popular?
>> >     Second question: Why isn't it possible to create issues in the urc=
u
>> >     repo? Im asking for a feature here:
>> >     Is it possible to make a function which checks if there are more
>> >     callbacks queued by call_rcu? I need that because there are some
>> >     callbacks which call call_rcu, and then calling rcu_barrier once
>> >     isn't enough and I therefore need a way to check if there are stil=
l
>> >     callbacks to wait on before terminating the program. No worries if
>> >     this is too much to ask for or if it isn't possible. This
>> >     functionality is only needed in termination because otherwise
>> >     isn't needed to call rcu_barrier multiple times (at least so far)
>> >
>> >     Best regards
>> >     Thobias
>> >
>> >
>>
>>
>> --
>> Mathieu Desnoyers
>> EfficiOS Inc.
>> https://www.efficios.com
>>
>

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

<div dir=3D"ltr">Figured out what rcu_read_ongoing does. It just returns tr=
ue if it&#39;s called within=C2=A0a read section and false otherwise. The p=
roblem for catching whether reads are done outside read sections is that yo=
u can not make macros for read and write operations. e.g. ptr-&gt;a =3D 4;.=
</div><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr"=
 class=3D"gmail_attr">tir. 2. sep. 2025 kl. 16:17 skrev Thobias Knudsen &lt=
;<a href=3D"mailto:[email protected]">[email protected]</a>&gt;:<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">&gt; I su=
spect that what you are trying to achieve is validation that<br>&gt; calls =
to functions that require to be within a RCU read-side critical<br>&gt; sec=
tion such as cds_lfht_lookup are indeed invoked from within a<br>&gt; criti=
cal section.<div><br></div><div>Yes exactly, but not only for read sections=
. It could also be to validate that rcu_barrier isnt=C2=A0called within a c=
allback function or that rcu_quiescent_state isnt called when thread is off=
line</div><div><br>&gt; We&#39;ve added a &quot;rcu_read_ongoing()&quot; AP=
I for that purpose to liburcu<br>&gt; RCU flavors, but AFAIK it&#39;s not u=
sed for any kind of validation<br>&gt; within cds_lfht. This could indeed b=
ecome a feature request that<br>&gt; would apply to all liburcu data struct=
ure APIs.<div><br></div><div>I can&#39;t find any documentation on rcu_read=
_ongoing. Btw the documentation for urcu in general is scattered all around=
 the repo it seems. It should have been all at one place imo. Should I make=
 a feature request for it? I don&#39;t know how stuff works inside this rep=
o though.</div><div><br></div><div><br></div></div></div><br><div class=3D"=
gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">man. 1. sep. 2025 kl. 17=
:09 skrev Mathieu Desnoyers &lt;<a href=3D"mailto:mathieu.desnoyers@efficio=
s.com" target=3D"_blank">[email protected]</a>&gt;:<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft:1px solid rgb(204,204,204);padding-left:1ex">On 2025-08-31 16:48, Thobi=
as Knudsen wrote:<br>
&gt; BTW i&#39;ve made a macro library which overrides the <br>
&gt; urcu=C2=A0and=C2=A0lfht=C2=A0functions. It checks that you call the fu=
nctions in the <br>
&gt; correct order. This has been really useful for debugging and I think i=
t <br>
&gt; would be useful to have it integrated into urcu to make the it more us=
er <br>
&gt; friendly. you could have it integrated=C2=A0with the macro DEBUG_RCU o=
r make <br>
&gt; a new one, maybe DEBUG_FUNCTION_CALL_ORDER. The only thing it doesn&#3=
9;t <br>
&gt; catch is if you continue to use data from cds_lfht_lookup() after <br>
&gt; rcu_read_unlock()<br>
<br>
I suspect that what you are trying to achieve is validation that<br>
calls to functions that require to be within a RCU read-side critical<br>
section such as cds_lfht_lookup are indeed invoked from within a<br>
critical section.<br>
<br>
We&#39;ve added a &quot;rcu_read_ongoing()&quot; API for that purpose to li=
burcu<br>
RCU flavors, but AFAIK it&#39;s not used for any kind of validation<br>
within cds_lfht. This could indeed become a feature request that<br>
would apply to all liburcu data structure APIs.<br>
<br>
Thanks,<br>
<br>
Mathieu<br>
<br>
&gt; <br>
&gt; s=C3=B8n. 31. aug. 2025 kl. 22:42 skrev Thobias Knudsen &lt;<a href=3D=
"mailto:[email protected]" target=3D"_blank">[email protected]</a> <br>
&gt; &lt;mailto:<a href=3D"mailto:[email protected]" target=3D"_blank">thob=
[email protected]</a>&gt;&gt;:<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0First question: why isn&#39;t Userspace RCU more po=
pular?<br>
&gt;=C2=A0 =C2=A0 =C2=A0Second question: Why isn&#39;t it possible to creat=
e issues in the urcu<br>
&gt;=C2=A0 =C2=A0 =C2=A0repo? Im asking for a feature here:<br>
&gt;=C2=A0 =C2=A0 =C2=A0Is it possible to make a function which checks if t=
here are more<br>
&gt;=C2=A0 =C2=A0 =C2=A0callbacks queued by call_rcu? I need that because t=
here are some<br>
&gt;=C2=A0 =C2=A0 =C2=A0callbacks which call call_rcu, and then calling rcu=
_barrier once<br>
&gt;=C2=A0 =C2=A0 =C2=A0isn&#39;t=C2=A0enough and I therefore need a way to=
 check if there are still<br>
&gt;=C2=A0 =C2=A0 =C2=A0callbacks to wait on before terminating the program=
. No worries if<br>
&gt;=C2=A0 =C2=A0 =C2=A0this is too much to ask for or if it isn&#39;t=C2=
=A0possible. This<br>
&gt;=C2=A0 =C2=A0 =C2=A0functionality is only needed in termination because=
 otherwise<br>
&gt;=C2=A0 =C2=A0 =C2=A0isn&#39;t=C2=A0needed to call rcu_barrier multiple =
times (at least so far)<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Best regards<br>
&gt;=C2=A0 =C2=A0 =C2=A0Thobias<br>
&gt; <br>
&gt; <br>
<br>
<br>
-- <br>
Mathieu Desnoyers<br>
EfficiOS Inc.<br>
<a href=3D"https://www.efficios.com" rel=3D"noreferrer" target=3D"_blank">h=
ttps://www.efficios.com</a><br>
</blockquote></div>
</blockquote></div>

--000000000000e68e4f063dd23eda--