On 2023-09-08 22:56, Stephen Hemminger wrote:
On Fri, 8 Sep 2023 22:48:54 +0200
Mattias Rönnblom <hof...@lysator.liu.se> wrote:
On 2023-09-07 17:24, Stephen Hemminger wrote:
Add missing locking so that if two non-EAL threads call rte_rand()
they will not corrupt the per-thread state.
Fixes: 3f002f069612 ("eal: replace libc-based random generation with LFSR")
The API documentation clearly states that no MT safety guarantees are
given for unregistered non-EAL threads. So this patch doesn't fix anything.
rte_rand() is MT safe for *registered* non-EAL threads.
Reading the documentation, it only guarantees safety if registered.
We should add an otherwise clause rather than leaving case as undefined.
I agree. It is MT safe in case only single unregistered non-EAL thread
uses the API (or multiple such threads, provided they are properly
[externally] serialized).
"If called from EAL threads, registered non-EAL threads or a *single*
unregistered non-EAL thread, this function is thread-safe. Multiple
unregistered non-EAL threads may not safely call this function in
parallel (i.e., must use external serialization)."
A lot of words, unfortunately. Maybe this is better:
"rte_xxx() is MT safe, with the exception it may not be called from
multiple *unregistered* non-EAL threads in parallel."
Then of course comes the issue that nobody knows what is an registered
non-EAL thread is. DPDK threading terminology is a big mess, so no wonder.