<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openbsd/src/lib/libc/include/thread_private.h, branch OPENBSD_7_9</title>
<subtitle>A mirror of https://github.com/libressl/openbsd.git
</subtitle>
<id>https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9</id>
<link rel='self' href='https://git.lua4.win/openbsd/atom?h=OPENBSD_7_9'/>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/'/>
<updated>2025-08-04T01:44:33+00:00</updated>
<entry>
<title>replace the flockfile backend with a per FILE recursive mutex.</title>
<updated>2025-08-04T01:44:33+00:00</updated>
<author>
<name>dlg</name>
<email></email>
</author>
<published>2025-08-04T01:44:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=97f291299e43eb39dd2ecdc18098d938d467dac6'/>
<id>urn:sha1:97f291299e43eb39dd2ecdc18098d938d467dac6</id>
<content type='text'>
the flockfile implementation in thread/rthread_file.c used an
external lock, and associated it with the relevant FILE * as needed.
this isn't great for a lot of reasons, complexity being the big
one, but the straw that broke the camels back is that it uses a
single spinlock to coordinate all of this, which in turn generates
a lot of sched_yield syscalls.

this avoids all the code complexity and the spinlock by just embedding
a small __rctmx in every FILE.

tested by and ok tb@ jca@
ok claudio@
</content>
</entry>
<entry>
<title>This thread-aware profiling support diff comes from Yuichiro NAITO.</title>
<updated>2025-07-16T16:22:58+00:00</updated>
<author>
<name>deraadt</name>
<email></email>
</author>
<published>2025-07-16T16:22:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=5506a044dc35162b58584a83a4099b4268ceba2a'/>
<id>urn:sha1:5506a044dc35162b58584a83a4099b4268ceba2a</id>
<content type='text'>
At runtime, profiling data is stored per-thread.  Upon termination, the
per-thread profiling data pools are merged into a into a single record,
which is then written out (using the new kernel-assisted system).  I think
the original gmon merging parts may have come from or been inspired by
someone at NetBSD.
This has been delayed because there were concerns about adding a TLS object
which would require other library cranks, so this rides all the major cranks
today.
ok kettenis tb claudio sthen etc etc etc
</content>
</entry>
<entry>
<title>add libc specific __cmtx and __rcmtx locks for internal use.</title>
<updated>2025-07-12T23:59:44+00:00</updated>
<author>
<name>dlg</name>
<email></email>
</author>
<published>2025-07-12T23:59:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=417b1213b262bbe6d34c708537dff4b062920bfa'/>
<id>urn:sha1:417b1213b262bbe6d34c708537dff4b062920bfa</id>
<content type='text'>
__cmtx provides mutual exclusion using futex(2) and cas on archs
that support it, or _spinlocks on the rest. __rcmtx is a recursive
mutex built on top of __cmtx, so it inherits the use of futex and
cas/spinlock from __cmtx.

until now the options we had for locking between threads in libc
were spinlocks or pthread mutexes. spinlocks use sched_yield to
relax if they have to spin on a contended lock, which we are trying
to minimise the use of as much as possible. pthread_mutex is
relatively large in memory and offers a lot of complicated features
which are unecessary for most of libc. the non cas/futex version
of pthread_mutexes currently relies on __thrsleep and __thrwakeup,
which we also want to deprecate.

having a small futex based lock available everywhere will help us
move away from overuse of spinlocks, and deprecate __thrsleep and
__thrwakeup.

ok kettenis@
jca@ provided his eyes too.
</content>
</entry>
<entry>
<title>Use struct __sFILE instead of FILE in thread locking callback</title>
<updated>2024-08-18T02:25:51+00:00</updated>
<author>
<name>guenther</name>
<email></email>
</author>
<published>2024-08-18T02:25:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=01a2985a38a3c808144fed57b482f1147af4d183'/>
<id>urn:sha1:01a2985a38a3c808144fed57b482f1147af4d183</id>
<content type='text'>
declarations to reduce &lt;stdio.h&gt; pollution.  Declare __isthreaded
in thread_private.h where it's really needed.

ok deraadt@
</content>
</entry>
<entry>
<title>Fix two issues related to thread private data in asr.</title>
<updated>2021-01-06T19:54:17+00:00</updated>
<author>
<name>otto</name>
<email></email>
</author>
<published>2021-01-06T19:54:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=a99f91343a365d71d137ae486285fdf049c5cf74'/>
<id>urn:sha1:a99f91343a365d71d137ae486285fdf049c5cf74</id>
<content type='text'>
- setting up asr in single thread mode and then starting threads using asr
  would lead to multiple threads sharing the same resolver.
- destruction of a thread that has been using asr would leak data.
Problem originally reported by Alexey Sokolov and Uli Schlachter.
ok kettenis@
</content>
</entry>
<entry>
<title>New futex(2) based rwlock implementation based on the mutex code.</title>
<updated>2019-02-13T13:22:14+00:00</updated>
<author>
<name>mpi</name>
<email></email>
</author>
<published>2019-02-13T13:22:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=1cc08e9dfa205222edf7fcc2dfc13ff00f572c84'/>
<id>urn:sha1:1cc08e9dfa205222edf7fcc2dfc13ff00f572c84</id>
<content type='text'>
This implementation reduces contention because threads no longer need
to spin calling sched_yield(2) before going to sleep.

Tested by many, thanks!

ok visa@, pirofti@
</content>
</entry>
<entry>
<title>Make the "not my pool" searching loop a tiny bit smarter, while</title>
<updated>2019-01-10T18:45:33+00:00</updated>
<author>
<name>otto</name>
<email></email>
</author>
<published>2019-01-10T18:45:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=93282eac7fa28695cb6880305f3757cbff94eca0'/>
<id>urn:sha1:93282eac7fa28695cb6880305f3757cbff94eca0</id>
<content type='text'>
making the number of pools variable.  Do not document the malloc
conf settings atm, don't know yet if they will stay.  Thanks to all
the testers. ok deraadt@
</content>
</entry>
<entry>
<title>Implement __cxa_thread_atexit to support C++11 thread_local scope.  The</title>
<updated>2017-12-05T13:45:31+00:00</updated>
<author>
<name>kettenis</name>
<email></email>
</author>
<published>2017-12-05T13:45:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=6995a7e31c862e513fc32eae98d52c8fc9e09580'/>
<id>urn:sha1:6995a7e31c862e513fc32eae98d52c8fc9e09580</id>
<content type='text'>
interface is also made available as __cxa_thread_atexit_impl to satisfy the
needs of GNU libstdc++.

ok guenther@, millert@
</content>
</entry>
<entry>
<title>Revert recent changes to unbreak ports/net/samba</title>
<updated>2017-11-04T22:53:57+00:00</updated>
<author>
<name>jca</name>
<email></email>
</author>
<published>2017-11-04T22:53:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=b30105a553258a2086424ddb4c40ae559cf8dc7c'/>
<id>urn:sha1:b30105a553258a2086424ddb4c40ae559cf8dc7c</id>
<content type='text'>
While it is not clear (to me) why that ports ends up with corrupted
shared libs, reverting those changes fixes the issue and should allow us
to close p2k17 more smoothly.

Discussed with a bunch, ok ajacoutot@ guenther@
</content>
</entry>
<entry>
<title>Change pthread_cleanup_{push,pop} to macros that store the cleanup info</title>
<updated>2017-10-28T21:23:14+00:00</updated>
<author>
<name>guenther</name>
<email></email>
</author>
<published>2017-10-28T21:23:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.lua4.win/openbsd/commit/?id=9990829d38e8d6b09ca6313b53ebc24368889ae0'/>
<id>urn:sha1:9990829d38e8d6b09ca6313b53ebc24368889ae0</id>
<content type='text'>
on the stack instead of mallocing the list and move the APIs from libpthread
to libc so that they can be used inside libc.

Note: the standard was explicitly written to permit/support this
"macro with unmatched brace" style and it's what basically everyone
else already does.  We xor the info with random cookies with a
random magic to detect/trip-up overwrites.

Major bump to both libc and libpthread due to the API move.

ok mpi@
</content>
</entry>
</feed>
