summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* MFC r303795:kib2016-08-201-1/+8
| | | | Add __cxa_thread_atexit(3) API implementation.
* MFC r303393:kib2016-08-033-7/+0
| | | | Remove empty initializer for the once facility.
* MFC r300970: Remove non-history libkse references and fix typojilles2016-06-181-3/+1
| | | | "PTHREAD_PROCESSES_PRIVATE".
* MFC r299114:kib2016-05-122-4/+2
| | | | | | | Do not leak THR_FLAGS_SUSPENDED from the previous suspend/resume cycle. PR: 209233
* MFC r297535:kib2016-04-112-2/+0
| | | | Remove unused variable.
* MFC r297139:kib2016-04-042-22/+2
| | | | | From libthr, remove special and strange code to set up session and control terminal, activated when running with pid 1.
* MFC r297137:kib2016-03-241-1/+1
| | | | Fix typo.
* MFC r295407:kib2016-03-124-4/+4
| | | | Make libc __pthread_map_stacks_exec() interposed.
* MFC r293858vangyzen2016-01-231-2/+3
| | | | | | | | | libthr: const-ify two variables Make the default umutex and urwlock initializers const, because they can be, and as a microoptimization. Sponsored by: Dell Inc.
* Disable SSE in libthrvangyzen2015-10-262-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang emits SSE instructions on amd64 in the common path of pthread_mutex_unlock. If the thread does not otherwise use SSE, this usage incurs a context-switch of the FPU/SSE state, which reduces the performance of multiple real-world applications by a non-trivial amount (3-5% in one application). Instead of this change, I experimented with eagerly switching the FPU state at context-switch time. This did not help. Most of the cost seems to be in the read/write of memory--as kib@ stated--and not in the #NM handling. I tested on machines with and without XSAVEOPT. One counter-argument to this change is that most applications already use SIMD, and the number of applications and amount of SIMD usage are only increasing. This is absolutely true. I agree that--in general and in principle--this change is in the wrong direction. However, there are applications that do not use enough SSE to offset the extra context-switch cost. SSE does not provide a clear benefit in the current libthr code with the current compiler, but it does provide a clear loss in some cases. Therefore, disabling SSE in libthr is a non-loss for most, and a gain for some. I refrained from disabling SSE in libc--as was suggested--because I can't make the above argument for libc. It provides a wide variety of code; each case should be analyzed separately. https://lists.freebsd.org/pipermail/freebsd-current/2015-March/055193.html Suggestions from: dim, jmg, rpaulo Sponsored by: Dell Inc.
* MFC r286582:kib2015-08-172-1/+9
| | | | Pre-resolve symbols required for the deferred signal processing.
* MFC r284385:kib2015-06-171-2/+2
| | | | Fix typo in comment.
* MFC r282948:kib2015-05-291-110/+91
| | | | | | Use bare mmap(2) to allocate space for the per-thread keys, instead of malloc(). This allows third party mallocs, which use pthread_setspecific(3) on the allocation path, to work.
* MFC r282057,r282092,r282106:ngie2015-05-133-13/+3
| | | | | | | | | | | | | | | | | | | | | | | | r282057: Build/install libc, librt, libthr, and msun NetBSD test suites on all architectures r282092 (by andrew): Correct the spelling of MACHINE_CPUARCH, MACHINE_CPU is not set on arm64. r282106: Remove per-architecture checks for enabling HAVE_FENV_H The conditional came from NetBSD, where only select architectures have this header/support All architectures on FreeBSD have the necessary support though, so the conditional's completely unnecessary make tinderbox done on all architectures (including arm64, where the issue occurred before) this time
* MFC r281857:pfg2015-04-291-1/+1
| | | | | | | | _pthread_cleanup_push: fix allocator sizeof operand mismatch Same fix appears to be in DragonFly's libthread_xu. Found by: Clang Static Analyzer
* MFC r281712:kib2015-04-251-0/+41
| | | | Make wait6(2), waitid(3) and ppoll(2) cancellation points.
* MFC r280818:kib2015-04-121-0/+24
| | | | Make kevent(2) a cancellation point.
* MFC r279284:kib2015-03-041-3/+4
| | | | Propagate errors from _thr_umutex_unlock2 through mutex_unlock_common.
* MFC r278627:kib2015-02-191-31/+11
| | | | Update libthr(3) man page to reflect the work done to support dlopen.
* MFC r278751:kib2015-02-173-8/+8
| | | | Properly interpose libc spinlocks, was missed in r276630.
* MFC r278313:kib2015-02-131-4/+1
| | | | Fully initialize allocated memory for the new barrier.
* MFC r277488:kib2015-01-241-1/+2
| | | | Do not allow pthread_sigmask() to block SIGCANCEL.
* Fix known issues which blow up the process after dlopen("libthr.so")kib2015-01-1810-546/+297
| | | | | | | | | | | | | | | | | | | | | (or loading a dso linked to libthr.so into process which was not linked against threading library). MFC r276630: Remove interposing, fix malloc, reinstall signal handlers wrappers on libthr load. MFC r276681: Avoid calling internal libc function through PLT or accessing data though GOT. MFC r277032: Reduce the size of the interposing table and amount of cancellation-handling code in the libthr. MFC note: r276646 ("do not erronously export 'openat' symbol from rtld") is not applicable to stable/10 yet, since PATHFDS support was not merged.
* MFC r274578,r274580:ngie2015-01-016-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | r274578: Add reachover Makefiles for contrib/netbsd-tests/lib/libpthread as lib/libthr/tests A variant of this code has been tested on amd64/i386 for some time by EMC/Isilon on 10-STABLE/11-CURRENT. It builds on other architectures, but the code will remain off until it's proven it works on virtual hardware or real hardware on other architectures Original work by: pho Sponsored by: EMC / Isilon Storage Division r274580: Add reachover Makefiles for contrib/netbsd-tests/lib/librt A variant of this code has been tested on amd64/i386 for some time by EMC/Isilon on 10-STABLE/11-CURRENT. It builds on other architectures, but the code will remain off until it's proven it works on virtual hardware or real hardware on other architectures Sponsored by: EMC / Isilon Storage Division
* MFC r272070:kib2014-10-151-2/+221
| | | | | | | | | Expand the libthr(3) manpage to document knobs accepted by libthr.so and explain some internal working of the library, neccessary to understand the knobs effects. MFC r272153 (by pluknet): Fix description of mutex acquisition.
* MFC r272069:kib2014-10-151-3/+4
| | | | | | Switch the defaults to not split the RLIMIT_STACK-sized initial thread stack into the stacks of the created threads. Add knob LIBPTHREAD_SPLITSTACK_MAIN to restore the older behaviour.
* MFC r269909:kib2014-08-162-1/+12
| | | | | | Add a knob LIBPTHREAD_BIGSTACK_MAIN, which instructs libthr to leave the whole RLIMIT_STACK-sized region of the kernel-allocated stack as the stack of main thread.
* MFC r269908:kib2014-08-161-1/+1
| | | | Style.
* MFC r266609:kib2014-06-072-4/+30
| | | | Change the _rtld_atfork() to lock the bind lock in write mode.
* MFC r261354:kib2014-02-081-5/+8
| | | | | | | In _pthread_kill(), if passed pthread is current thread, do not send the signal second time, by adding the missed else before if statement. PR: threads/186309
* MFC r258499:kib2013-11-302-2/+10
| | | | | | | Fix for the spurious signal handler call with zero signo in the threaded process. Approved by: re (hrs)
* The SUSv4tc1 requires that pthread_setcancelstate() shall be not akib2013-06-191-1/+2
| | | | | | | | | cancellation point. When enabling the cancellation, only process the pending cancellation for asynchronous mode. Reported and reviewed by: Kohji Okuno <okuno.kohji@jp.panasonic.com> Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Since the cause of the problems with the __fillcontextx() waskib2013-06-031-15/+7
| | | | | | | | | identified, unify the code of check_deferred_signal() for all architectures, making the variant under #ifdef x86 common. Tested by: marius (sparc64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* The getcontext() from the __fillcontextx() call in thekib2013-05-281-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | check_deferred_signal() returns twice, since handle_signal() emulates the return from the normal signal handler by sigreturn(2)ing the passed context. Second return is performed on the destroyed stack frame, because __fillcontextx() has already returned. This causes undefined and bad behaviour, usually the victim thread gets SIGSEGV. Avoid nested frame and the need to return from it by doing direct call to getcontext() in the check_deferred_signal() and using a new private libc helper __fillcontextx2() to complement the context with the extended CPU state if the deferred signal is still present. The __fillcontextx() is now unused, but is kept to allow older libthr.so to be used with the new libc. Mark __fillcontextx() as returning twice [1]. Reported by: pgj Pointy hat to: kib Discussed with: dim Tested by: pgj, dim Suggested by: jilles [1] MFC after: 1 week
* Partially apply the capitalization of the heading word of the sequencekib2013-05-271-3/+3
| | | | | | | and fix typo. Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Return one-based key so that user can check if the key is ever allocateddavidxu2013-05-161-4/+7
| | | | | | in the first place. Initial patch submitted by: phk
* Fix return value for setcontext and swapcontext.davidxu2013-05-091-4/+8
|
* Add accept4() system call.jilles2013-05-012-0/+27
| | | | | | | | | | | | | | | The accept4() function, compared to accept(), allows setting the new file descriptor atomically close-on-exec and explicitly controlling the non-blocking status on the new socket. (Note that the latter point means that accept() is not equivalent to any form of accept4().) The linuxulator's accept4 implementation leaves a race window where the new file descriptor is not close-on-exec because it calls sys_accept(). This implementation leaves no such race window (by using falloc() flags). The linuxulator could be fixed and simplified by using the new code. Like accept(), accept4() is async-signal-safe, a cancellation point and permitted in capability mode.
* Remove extra code for SA_RESETHAND, it is not needed because kernel hasdavidxu2013-04-281-7/+0
| | | | already done this.
* libthr: Fix a parameter name in an internal header file.jilles2013-04-271-1/+1
|
* Remove debug code.davidxu2013-04-181-1/+0
|
* Avoid copying memory if SIGCANCEL is not masked.davidxu2013-04-181-4/+14
|
* Revert revision 249323, the PR/177624 is confusing, that bug is causeddavidxu2013-04-181-1/+10
| | | | | by using buggy getcontext/setcontext on same stack, while swapcontext normally works on different stack, there is no such a problem.
* libthr: Remove _thr_rtld_fini(), unused since r245630.jilles2013-04-122-12/+0
|
* swapcontext wrapper can not be implemented in C, the stack pointer saved indavidxu2013-04-101-10/+1
| | | | | | the context becomes invalid when the function returns, same as setjmp, it must be implemented in assemble language, see discussions in PR misc/177624.
* libthr: Always use the threaded rtld lock implementation.jilles2013-01-182-5/+6
| | | | | | | | | | | The threaded rtld lock implementation is faster even in the single-threaded case because it postpones signal handlers via THR_CRITICAL_ENTER and THR_CRITICAL_LEAVE instead of calling sigprocmask(2). As a result, exception handling becomes faster in single-threaded applications linked with libthr. Reviewed by: kib
* In suspend_common(), don't wait for a thread which is in creation, becausedavidxu2012-08-275-4/+64
| | | | | | | pthread_suspend_all_np() may have already suspended its parent thread. Add locking code in pthread_suspend_all_np() to only allow one thread to suspend other threads, this eliminates a deadlock where two or more threads try to suspend each others.
* Eliminate redundant code, _thr_spinlock_init() has already been calleddavidxu2012-08-231-3/+0
| | | | in init_private(), don't call it again in fork() wrapper.
* Implement syscall clock_getcpuclockid2, so we can get a clock iddavidxu2012-08-171-1/+3
| | | | | | | | for process, thread or others we want to support. Use the syscall to implement POSIX API clock_getcpuclock and pthread_getcpuclockid. PR: 168417
* Merging of projects/armv6, part 2gonzo2012-08-151-1/+13
| | | | Handle TLS for ARMv6 and ARMv7
OpenPOWER on IntegriCloud