summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* Make openat(2) a cancellation point.jilles2009-10-113-0/+34
| | | | | | | This is required by POSIX and matches open(2). Reviewed by: kib, jhb MFC after: 1 month
* don't report error if key was deleted.davidxu2009-09-251-1/+11
| | | | PR: threads/135462
* rwlock implemented from libthr need to fall through the 'hard path' andattilio2009-09-231-2/+5
| | | | | | | | | | | | | | | | | | | | query umtx also if the shared waiters bit is set on a shared lock. The writer starvation avoidance technique, infact, can lead to shared waiters on a shared lock which can bring to a missed wakeup and thus to a deadlock if the right bit is not checked (a notable case is the writers counterpart to be handled through expired timeouts). Fix that by checking for the shared waiters bit also when unlocking the shared locks. That bug was causing a reported MySQL deadlock. Many thanks go to Nick Esborn and his employer DesertNet which provided time and machines to identify and fix this issue. PR: thread/135673 Reported by: Nick Esborn <nick at desert dot net> Tested by: Nick Esborn <nick at desert dot net> Reviewed by: jeff
* In the current code, rdlock_count is not correctly handled for some cases.attilio2009-07-062-1/+4
| | | | | | | | | | | | | | | The most notable is that it is not bumped in rwlock_rdlock_common() when the hard path (__thr_rwlock_rdlock()) returns successfully. This can lead to deadlocks in libthr when rwlocks recursion in read mode happens. Fix the interested parts by correctly handling rdlock_count. PR: threads/136345 Reported by: rink Tested by: rink Reviewed by: jeff Approved by: re (kib) MFC: 2 weeks
* These are some cosmetic changes to improve the clarity of libthr's fork ↵green2009-05-111-9/+9
| | | | implementation.
* Now that the kernel defines CACHE_LINE_SIZE in machine/param.h, userwatson2009-04-191-2/+0
| | | | | | | | that definition in the custom locking code for the run-time linker rather than local definitions. Pointed out by: tinderbox MFC after: 2 weeks
* Turn on nodelete linker flag because libthr can not be unloaded safely,davidxu2009-03-311-0/+1
| | | | it does hook on to libc.
* Forcibly unlock the malloc() locks in the child process after fork(),kib2009-03-191-1/+4
| | | | | | | by temporary pretending that the process is still multithreaded. Current malloc lock primitives do nothing for singlethreaded process. Reviewed by: davidxu, deischen
* Don't ignore other fcntl functions, directly call __sys_fcntl ifdavidxu2009-03-091-1/+1
| | | | | | WITHOUT_SYSCALL_COMPAT is not defined. Reviewed by: deischen
* Don't reference non-existent __fcntl_compat if WITHOUT_SYSCALL_COMPAT is ↵davidxu2009-03-092-0/+10
| | | | | | defined. Submitted by: Pawel Worach "pawel dot worach at gmail dot com"
* With only one threading library, simplify the logic of setting SHLIBDIR.ru2009-02-241-4/+2
|
* Fix build when WITH_SSP is set explicitly.ru2009-02-211-2/+1
| | | | Submitted by: Jeremie Le Hen
* Honor WITHOUT_INSTALLLIB in some places.jkim2009-02-131-0/+2
|
* When libthr and rtld start up, there are a number of magic spells castpeter2008-12-071-1/+1
| | | | | | | | | | | | | | in order to get the symbol binding state "just so". This is to allow locking to be activated and not run into recursion problems later. However, one of the magic bits involves an explicit call to _umtx_op() to force symbol resolution. It does a wakeup operation on a fake, uninitialized (ie: random contents) umtx. Since libthr isn't active, this is harmless. Nothing can match the random wakeup. However, valgrind finds this and is not amused. Normally I'd just write a suppression record for it, but the idea of passing random args to syscalls (on purpose) just doesn't feel right.
* Provide custom simple allocator for rtld locks in libthr. The allocatorkib2008-12-022-24/+24
| | | | | | | | | does not use any external symbols, thus avoiding possible recursion into rtld to resolve symbols, when called. Reviewed by: kan, davidxu Tested by: rink MFC after: 1 month
* Invoke _rtld_atfork_post earlier, before we reinitialize rtld lockskan2008-12-011-3/+4
| | | | | | | | | | | | by switching into single-thread mode. libthr ignores broken use of lock bitmaps used by default rtld locking implementation, this in turn turns lock handoff in _rtld_thread_init into NOP. This in turn makes child processes of forked multi-threaded programs to run with _thr_signal_block still in effect, with most signals blocked. Reported by: phk, kib
* Unlock the malloc() locks in the child process after fork(). This giveskib2008-11-291-0/+1
| | | | | | | | | | | | | us working malloc in the fork child of the multithreaded process. Although POSIX requires that only async-signal safe functions shall be operable after fork in multithreaded process, not having malloc lower the quality of our implementation. Tested by: rink Discussed with: kan, davidxu Reviewed by: kan MFC after: 1 month
* Add two rtld exported symbols, _rtld_atfork_pre and _rtld_atfork_post.kib2008-11-271-1/+10
| | | | | | | | | | | | | | Threading library calls _pre before the fork, allowing the rtld to lock itself to ensure that other threads of the process are out of dynamic linker. _post releases the locks. This allows the rtld to have consistent state in the child. Although child may legitimately call only async-safe functions, the call may need plt relocation resolution, and this requires working rtld. Reported and debugging help by: rink Reviewed by: kan, davidxu MFC after: 1 month (anyway, not before 7.1 is out)
* Allow psaddr_t to be widened by using thr_pread_{int,long,ptr},marcel2008-09-141-2/+2
| | | | | | | where critical. Some places still use ps_pread/ps_pwrite directly, but only need changed when byte-order comes into the picture. Also, change th_p in td_event_msg_t from a pointer type to psaddr_t, so that events also work when psaddr_t is widened.
* Move call to _malloc_thread_cleanup() so that if this is the last thread,jasone2008-09-091-3/+6
| | | | | | | the call never happens. This is necessary because malloc may be used during exit handler processing. Submitted by: davidxu
* Add thread-specific caching for small size classes, based on magazines.jasone2008-08-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | This caching allows for completely lock-free allocation/deallocation in the steady state, at the expense of likely increased memory use and fragmentation. Reduce the default number of arenas to 2*ncpus, since thread-specific caching typically reduces arena contention. Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced, cacheline-spaced, and subpage-spaced size classes. The advantages are: fewer size classes, reduced false cacheline sharing, and reduced internal fragmentation for allocations that are slightly over 512, 1024, etc. Increase RUN_MAX_SMALL, in order to limit fragmentation for the subpage-spaced size classes. Add a size-->bin lookup table for small sizes to simplify translating sizes to size classes. Include a hard-coded constant table that is used unless custom size class spacing is specified at run time. Add the ability to disable tiny size classes at compile time via MALLOC_TINY.
* In function pthread_condattr_getpshared, store result correctly.davidxu2008-08-011-1/+1
| | | | PR: kern/126128
* Enable GCC stack protection (aka Propolice) for userland:ru2008-06-251-0/+2
| | | | | | | | | | | | | | | | | | | | | - It is opt-out for now so as to give it maximum testing, but it may be turned opt-in for stable branches depending on the consensus. You can turn it off with WITHOUT_SSP. - WITHOUT_SSP was previously used to disable the build of GNU libssp. It is harmless to steal the knob as SSP symbols have been provided by libc for a long time, GNU libssp should not have been much used. - SSP is disabled in a few corners such as system bootstrap programs (sys/boot), process bootstrap code (rtld, csu) and SSP symbols themselves. - It should be safe to use -fstack-protector-all to build world, however libc will be automatically downgraded to -fstack-protector because it breaks rtld otherwise. - This option is unavailable on ia64. Enable GCC stack protection (aka Propolice) for kernel: - It is opt-out for now so as to give it maximum testing. - Do not compile your kernel with -fstack-protector-all, it won't work. Submitted by: Jeremie Le Hen <jeremie@le-hen.org>
* Add two commands to _umtx_op system call to allow a simple mutex to bedavidxu2008-06-243-54/+106
| | | | | | | | | | | | | | locked and unlocked completely in userland. by locking and unlocking mutex in userland, it reduces the total time a mutex is locked by a thread, in some application code, a mutex only protects a small piece of code, the code's execution time is less than a simple system call, if a lock contention happens, however in current implemenation, the lock holder has to extend its locking time and enter kernel to unlock it, the change avoids this disadvantage, it first sets mutex to free state and then enters kernel and wake one waiter up. This improves performance dramatically in some sysbench mutex tests. Tested by: kris Sounds great: jeff
* Make pthread_cleanup_push() and pthread_cleanup_pop() as a pair of macros,davidxu2008-06-093-22/+50
| | | | | | | use stack space to keep cleanup information, this eliminates overhead of calling malloc() and free() in thread library. Discussed on: thread@
* Call the fcntl compatiblity wrapper from the thread library fcntl wrappersdfr2008-05-301-1/+2
| | | | | | so that they get the benefit of the (limited) forward ABI compatibility. MFC after: 1 week
* Eliminate global mutex by using pthread_once's state field asdavidxu2008-05-301-33/+29
| | | | a semaphore.
* - Reduce function call overhead for uncontended case.davidxu2008-05-293-217/+104
| | | | | - Remove unused flags MUTEX_FLAGS_* and their code. - Check validity of the timeout parameter in mutex_self_lock().
* Commit missing mips libthr support that I thought I'd committed earlierimp2008-05-112-0/+141
|
* Remove libc_r's remnant code.davidxu2008-05-061-16/+0
|
* Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to savedavidxu2008-04-299-19/+20
| | | | time in kernel(avoid VM lookup).
* Increase the default MUTEX_ADAPTIVE_SPINS to 2000, after furtherkris2008-04-261-1/+1
| | | | | | | | testing it turns out 200 was too short to give good adaptive performance. Reviewed by: jeff MFC after: 1 week
* Bring in mips threads support from perforce mips2-jnpr branch.imp2008-04-261-0/+5
|
* Avoid various shadowed variables. libthr is now almost WARNS=4 clean exceptdelphij2008-04-234-25/+25
| | | | | | for some const dequalifiers that needs more careful investigation. Ok'ed by: davidxu
* Use native rwlock.davidxu2008-04-221-54/+20
|
* _vfork is not in libthr, remove the reference.davidxu2008-04-161-1/+0
|
* don't include pthread_np.h, it is not used.davidxu2008-04-141-1/+0
|
* put THR_CRITICAL_LEAVE into do .. while statement.davidxu2008-04-031-2/+4
|
* add __hidden suffix to _umtx_op_err, this eliminates PLT.davidxu2008-04-031-1/+1
|
* Non-portable functions are in pthread_np.h, fix compiling problem.davidxu2008-04-021-1/+1
|
* Add pthread_setaffinity_np and pthread_getaffinity_np to libc namespace.davidxu2008-04-021-2/+0
|
* Remove unused functions.davidxu2008-04-022-55/+0
|
* Replace function _umtx_op with _umtx_op_err, the later function directlydavidxu2008-04-029-51/+112
| | | | | | returns errno, because errno can be mucked by user's signal handler and most of pthread api heavily depends on errno to be correct, this change should improve stability of the thread library.
* Replace userland rwlock with a pure kernel based rwlock, the newdavidxu2008-04-024-223/+199
| | | | | | implementation does not switch pointers when it resumes waiters. Asked by: jeff
* Restore normal pthread_cond_signal path to avoid some obscure races.davidxu2008-04-011-2/+3
|
* return EAGAIN early rather than running bunch of code later, micro optimizedavidxu2008-04-011-1/+3
| | | | static branch prediction.
* Rewrite rwlock to user atomic operations to change rwlock state, thisdavidxu2008-03-313-141/+281
| | | | | | | eliminates internal mutex lock contention when most rwlock operations are read. Orignal patch provided by: jeff
* Remove options MK_LIBKSE and DEFAULT_THREAD_LIB now that we no longerru2008-03-291-4/+1
| | | | build libkse. This should fix WITHOUT_LIBTHR builds as a side effect.
* Compile libthr with warnings.ru2008-03-253-6/+9
|
* Fixed mis-implementation of pthread_mutex_get{spin,yield}loops_np().ru2008-03-251-4/+7
| | | | Reviewed by: davidxu
OpenPOWER on IntegriCloud