libthr: Add missing END() directive for umtx_op_err (amd64)Like r353929, related to D22122. No functional change.Reviewed by: emaste, kib (earlier version both)
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.
Disable SSE in libthrClang emits SSE instructions on amd64 in the common path ofpthread_mutex_unlock. If the thread does not otherwise use SSE,this usage incurs a context-switch of the FPU/SSE s
Disable SSE in libthrClang emits SSE instructions on amd64 in the common path ofpthread_mutex_unlock. If the thread does not otherwise use SSE,this usage incurs a context-switch of the FPU/SSE state, whichreduces the performance of multiple real-world applications by anon-trivial amount (3-5% in one application).Instead of this change, I experimented with eagerly switching theFPU state at context-switch time. This did not help. Most of thecost seems to be in the read/write of memory--as kib@ stated--andnot in the #NM handling. I tested on machines with and withoutXSAVEOPT.One counter-argument to this change is that most applications alreadyuse SIMD, and the number of applications and amount of SIMD usageare only increasing. This is absolutely true. I agree that--ingeneral and in principle--this change is in the wrong direction.However, there are applications that do not use enough SSE to offsetthe extra context-switch cost. SSE does not provide a clear benefitin the current libthr code with the current compiler, but it doesprovide a clear loss in some cases. Therefore, disabling SSE inlibthr is a non-loss for most, and a gain for some.I refrained from disabling SSE in libc--as was suggested--becauseI can't make the above argument for libc. It provides a wide varietyof code; each case should be analyzed separately.https://lists.freebsd.org/pipermail/freebsd-current/2015-March/055193.htmlSuggestions from: dim, jmg, rpauloApproved by: kib (mentor)MFC after: 2 weeksSponsored by: Dell Inc.
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
Add section .note.GNU-stack for assembly files used by 386 and amd64.
Merge from tbemd, with a small amount of rework:For all libthr contexts, use ${MACHINE_CPUARCH}for all libc contexts, use ${MACHINE_ARCH} if it exists, otherwise use${MACHINE_CPUARCH}Move some co
Merge from tbemd, with a small amount of rework:For all libthr contexts, use ${MACHINE_CPUARCH}for all libc contexts, use ${MACHINE_ARCH} if it exists, otherwise use${MACHINE_CPUARCH}Move some common code up a layer (the .PATH statement was the same inall the arch submakefiles).# Hope she hasn't busted powerpc64 with this...
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.
style.Makefile(5)
- 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
Add AMD64 support code.