summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* Fix description of mutex acquisition.pluknet2014-09-261-2/+8
| | | | | | Reviewed by: kib X-MFC with: r272070 Sponsored by: Nginx, Inc.
* Expand the libthr(3) manpage to document knobs accepted by libthr.sokib2014-09-241-2/+215
| | | | | | | | | and explain some internal working of the library, neccessary to understand the knobs effects. Reviewed by: bjk, pluknet Sponsored by: The FreeBSD Foundation MFC after: 3 weeks
* Switch the defaults to not split the RLIMIT_STACK-sized initial threadkib2014-09-241-3/+4
| | | | | | | | stack into the stacks of the created threads. Add knob LIBPTHREAD_SPLITSTACK_MAIN to restore the older behaviour. Sponsored by: The FreeBSD Foundation MFC after: 3 weeks
* Fix typo in a comment.rpaulo2014-09-021-1/+1
|
* Add a knob LIBPTHREAD_BIGSTACK_MAIN, which instructs libthr to leavekib2014-08-132-1/+12
| | | | | | | | | | | | | | | | | the whole RLIMIT_STACK-sized region of the kernel-allocated stack as the stack of main thread. By default, the main thread stack is clamped at 2MB (4MB on 64bit ABIs) and the rest is used for other threads stack allocation. Since there is no programmatic way to adjust the size of the main thread stack, pthread_attr_setstacksize() is too late, the knob allows user to manage the main stack size both for single-threaded and multi-threaded processes with the rlimit. Reported by: "Ivan A. Kosarev" <ivan@ivan-labs.com> Tested by: dim Sponsored by: The FreeBSD Foundation MFC after: 3 days
* Style.kib2014-08-131-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days
* Remove ia64.marcel2014-07-074-174/+0
| | | | | | | | | | | | | | | | | This includes: o All directories named *ia64* o All files named *ia64* o All ia64-specific code guarded by __ia64__ o All ia64-specific makefile logic o Mention of ia64 in comments and documentation This excludes: o Everything under contrib/ o Everything under crypto/ o sys/xen/interface o sys/sys/elf_common.h Discussed at: BSDcan
* Add the DTrace probe definitions for plockstat support.rpaulo2014-07-051-0/+46
| | | | | | This will be connected to the system later. Sponsored by: The FreeBSD Foundation
* use .Mt to mark up email addresses consistently (part3)bapt2014-06-231-4/+4
| | | | | PR: 191174 Submitted by: Franco Fichtner <franco at lastsummer.de>
* Right now, the rtld prefork hook locks the rtld bind lock in the readkib2014-05-242-4/+30
| | | | | | | | | | | | | | | | | | mode. This allows the binder to be functional in the child after the fork (assuming no lazy loading of a filter is needed), but other rtld services which require write lock on rtld_bind_lock cause deadlock, if called by child. Change the _rtld_atfork() to lock the bind lock in write mode, making the rtld fully functional after the fork. Pre-resolve the symbols which are called by the libthr' fork() interposer, since dynamic resolution causes deadlock due to the rtld_bind_lock already owned in the write mode. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Use src.opts.mk in preference to bsd.own.mk except where we need stuffimp2014-05-061-1/+1
| | | | from the latter.
* Convert from WITHOUT_SYSCALL_COMPAT to MK_SYSCALL_COMPAT.imp2014-04-051-1/+1
|
* In _pthread_kill(), if passed pthread is current thread, do not sendkib2014-02-011-5/+8
| | | | | | | | | | | the signal second time, by adding the missed else before if statement. While there, postpone initializing local curthread variable until passed signal number is checked for validity. Submitted by: John Wolfe <jlw@xinuos.com> PR: threads/186309 MFC after: 1 week
* If check_deferred_signal() execution needs binding of PLT symbol,kib2013-11-232-2/+10
| | | | | | | | | | | | | | | | | | | | | | | unlocking the rtld bind lock results in the processing of ast and recursing into the check_deferred_signal(). Nested execution of check_deferred_signal() delivers the signal to user code and clears si_signo. On return, top-level check_deferred_signal() frame continues delivering the same signal one more time, but now with zero si_signo. Fix this by adding a flag to indicate that deferred delivery is running, so check_deferred_signal() should avoid doing anything. Since user signal handler is allowed to modify the passed machine context to make return from the signal handler to cause arbitrary jump, or do longjmp(). For this case, also clear the flag in thr_sighandler(), since kernel signal delivery means that nested delivery code should not run right now. Reported by: Vitaly Magerya <vmagerya@gmail.com> Reviewed by: davidxu, jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
* 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
* Do defered mutex wakeup once.davidxu2012-08-121-0/+1
|
* MFp4:davidxu2012-08-115-24/+38
| | | | | Further decreases unexpected context switches by defering mutex wakeup until internal sleep queue lock is released.
* Don't forget to initialize return value.davidxu2012-07-201-1/+1
|
* Simplify code by replacing _thr_ref_add() with _thr_find_thread().davidxu2012-07-201-5/+1
|
* Eliminate duplicated code.davidxu2012-07-201-19/+10
|
* Don't assign same value.davidxu2012-07-202-6/+4
|
* Eliminate duplicated code.davidxu2012-07-201-29/+14
|
* Eliminate duplicated code.davidxu2012-07-201-30/+16
|
* Don't forget to release a thread reference count,davidxu2012-07-201-4/+2
| | | | | | | replace _thr_ref_add() with _thr_find_thread(), so reference count is no longer needed. MFC after: 3 days
* Return EBUSY for PTHREAD_MUTEX_ADAPTIVE_NP too when the mutex could notdavidxu2012-05-271-0/+1
| | | | | | | be acquired. PR: 168317 MFC after: 3 days
* Create a common function lookup() to search a chan, this eliminatesdavidxu2012-05-101-5/+9
| | | | redundant SC_LOOKUP() calling.
* Fix mis-merged line, move SC_LOOKUP() call todavidxu2012-05-051-1/+1
| | | | upper level.
* MFp4:davidxu2012-05-033-1/+10
| | | | | | | Enqueue thread in LIFO, this can cause starvation, but it gives better performance. Use _thr_queuefifo to control the frequency of FIFO vs LIFO, you can use environment string LIBPTHREAD_QUEUE_FIFO to configure the variable.
* Set SIGCANCEL to SIGTHR as part of some cleanup of DTrace code.gnn2012-04-181-1/+1
| | | | | Reviewed by: davidxu@ MFC after: 1 week
* umtx operation UMTX_OP_MUTEX_WAKE has a side-effect that it accessesdavidxu2012-04-052-5/+18
| | | | | | | | | | | | | | | | | | | | | a mutex after a thread has unlocked it, it event writes data to the mutex memory to clear contention bit, there is a race that other threads can lock it and unlock it, then destroy it, so it should not write data to the mutex memory if there isn't any waiter. The new operation UMTX_OP_MUTEX_WAKE2 try to fix the problem. It requires thread library to clear the lock word entirely, then call the WAKE2 operation to check if there is any waiter in kernel, and try to wake up a thread, if necessary, the contention bit is set again by the operation. This also mitgates the chance that other threads find the contention bit and try to enter kernel to compete with each other to wake up sleeping thread, this is unnecessary. With this change, the mutex owner is no longer holding the mutex until it reaches a point where kernel umtx queue is locked, it releases the mutex as soon as possible. Performance is improved when the mutex is contensted heavily. On Intel i3-2310M, the runtime of a benchmark program is reduced from 26.87 seconds to 2.39 seconds, it even is better than UMTX_OP_MUTEX_WAKE which is deprecated now. http://people.freebsd.org/~davidxu/bench/mutex_perf.c
* libthr: In the atfork handlers for signals, do not skip the last signal.jilles2012-03-261-3/+3
| | | | | | | | _SIG_MAXSIG works a bit unexpectedly: signals 1 till _SIG_MAXSIG are valid, both bounds inclusive. Reviewed by: davidxu MFC after: 1 week
* Use clockid parameter instead of hard-coded CLOCK_REALTIME.davidxu2012-03-191-1/+1
| | | | Reported by: pjd
OpenPOWER on IntegriCloud