Fix initial exec TLS mode for dynamically loaded shared objects.If dso uses initial exec TLS mode, rtld tries to allocate TLS instatic space. If there is no space left, the dlopen(3) fails. If spa
Fix initial exec TLS mode for dynamically loaded shared objects.If dso uses initial exec TLS mode, rtld tries to allocate TLS instatic space. If there is no space left, the dlopen(3) fails. If spaceif allocated, initial content from PT_TLS segment is distributed toall threads' pcbs, which was missed and caused un-initialized TLSsegment for such dso after dlopen(3).The mode is auto-detected either due to the relocation used, or if theDF_STATIC_TLS dynamic flag is set. In the later case, the TLS segmentis tried to allocate earlier, which increases chance of the dlopen(3)to succeed. LLD was recently fixed to properly emit the flag, ld.bdfdid it always.Initial test by: dumbbellTested by: emaste (amd64), ian (arm)Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64)Sponsored by: The FreeBSD FoundationMFC after: 2 weeksDifferential revision: https://reviews.freebsd.org/D19072
show more ...
lib: further adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using mis-identified many licenses so this was mostly a manual - errorpr
lib: further adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using mis-identified many licenses so this was mostly a manual - errorprone - task.The Software Package Data Exchange (SPDX) group provides a specificationto make it easier for automated tools to detect and summarize well knownopensource licenses. We are gradually adopting the specification, notingthat the tags are considered only advisory and do not, in any way,superceed or replace the license texts.
Merge all the copies of _tcb_ctor and _tcb_dtor.The amd64, i386, and sparc64 versions were identical, with the onedifference where the former two used inline asm instead of _tcb_get. Ihave compar
Merge all the copies of _tcb_ctor and _tcb_dtor.The amd64, i386, and sparc64 versions were identical, with the onedifference where the former two used inline asm instead of _tcb_get. Ihave compared the function before and after replacing the asm with _tcb_getand found the object files to be identical.The arm, mips, and powerpc versions were almost identical. The onlydifference was the powerpc version used an alignment of 1 where arm andmips used 16. As this is an increase in alignment is will be safe.Along with this arm, mips, and powerpc all passed, when initial was true,the value returned from _tcb_get as the first argument to_rtld_allocate_tls. This would then return this pointer back to the caller.We can remove these extra calls by checking if initial is set and settingthe thread control block directly. As this is what the sparc64 code doeswe can use it directly.As after these observations all the architectures can now have identicalcode we can merge them into a common file.Differential Revision: https://reviews.freebsd.org/D1556Reviewed by: kibSponsored by: The FreeBSD Foundation
The TCB_GET32() and TCB_GET64() macros in the i386 and amd64-specificversions of pthread_md.h have a special case of dereferencing a nullpointer. Clang warns about this with:In file included fro
The TCB_GET32() and TCB_GET64() macros in the i386 and amd64-specificversions of pthread_md.h have a special case of dereferencing a nullpointer. Clang warns about this with:In file included from lib/libthr/arch/i386/i386/pthread_md.c:36:lib/libthr/arch/i386/include/pthread_md.h:96:10: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference] return (TCB_GET32(tcb_self)); ^~~~~~~~~~~~~~~~~~~lib/libthr/arch/i386/include/pthread_md.h:73:13: note: expanded from: : "m" (*(u_int *)(__tcb_offset(name)))); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~lib/libthr/arch/i386/include/pthread_md.h:96:10: note: consider using __builtin_trap() or qualifying pointer with 'volatile'Since this indirection is done relative to the fs or gs segment, toretrieve thread-specific data, it is an exception to the rule.Therefore, add a volatile qualifier to tell the compiler we really wantto dereference a zero address.MFC after: 1 week
Replace function _umtx_op with _umtx_op_err, the later function directlyreturns errno, because errno can be mucked by user's signal handler andmost of pthread api heavily depends on errno to be cor
Replace function _umtx_op with _umtx_op_err, the later function directlyreturns errno, because errno can be mucked by user's signal handler andmost of pthread api heavily depends on errno to be correct, this changeshould improve stability of the thread library.
- Remove variable _thr_scope_system, all threads are system scope.- Rename _thr_smp_cpus to boolean variable _thr_is_smp.- Define CPU_SPINWAIT macro for each arch, only X86 supports it.
Remove declaration of _thr_initial from MD header file, it is no longerneeded.
Simplify _get_curthread() and _tcb_ctor because libc and rtld nowalready allocate thread pointer space in tls block for initial thread.Only i386 and amd64 have been done, others still have to be te
Simplify _get_curthread() and _tcb_ctor because libc and rtld nowalready allocate thread pointer space in tls block for initial thread.Only i386 and amd64 have been done, others still have to be tested.
Import my recent 1:1 threading working. some features improved includes: 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchroni
Import my recent 1:1 threading working. some features improved includes: 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform.As the result, some mysql super-smack benchmarks show performance isimproved massivly.Okayed by: jeff, mtm, rwatson, scottl