summaryrefslogtreecommitdiffstats
path: root/lib/libthr
Commit message (Collapse)AuthorAgeFilesLines
* Fix SVN mismerge. We somehow ended up with the 32-bit powerpc versionnwhitehorn2010-07-112-4/+4
| | | | in arch/powerpc64 instead of the 64-bit one.
* Powerpc64 thread libraries support.nwhitehorn2010-07-103-0/+143
|
* Coalesce one more broken line.deischen2010-05-241-2/+1
|
* Coalesce a couple of broken lines since they can fit within 80deischen2010-05-241-4/+2
| | | | characters. Little nit found while looking at a bug report.
* mdoc: order prologue macros consistently by Dd/Dt/Osuqs2010-04-141-1/+1
| | | | | | | | Although groff_mdoc(7) gives another impression, this is the ordering most widely used and also required by mdocml/mandoc. Reviewed by: ru Approved by: philip, ed (mentors)
* Merge r195129 from project/mips to head by hand:imp2010-01-091-2/+6
| | | | | r195129 | gonzo | 2009-06-27 17:28:56 -0600 (Sat, 27 Jun 2009) | 2 lines - Use sysarch(2) in MIPS version of _tcb_set/_tcb_get
* remove file thr_sem_new.c.davidxu2010-01-051-1/+0
|
* Remove extra new semaphore stubs, because libc already has them, anddavidxu2010-01-052-110/+0
| | | | | | ld can find the newest version which is default. Poked by: kan@
* Use umtx to implement process sharable semaphore, to make this work,davidxu2010-01-056-232/+172
| | | | | | | | | | | | | | | | | | | | | | now type sema_t is a structure which can be put in a shared memory area, and multiple processes can operate it concurrently. User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open() to initialize a shared semaphore. Named semaphore uses file system and is located in /tmp directory, and its file name is prefixed with 'SEMD', so now it is chroot or jail friendly. In simplist cases, both for named and un-named semaphore, userland code does not have to enter kernel to reduce/increase semaphore's count. The semaphore is designed to be crash-safe, it means even if an application is crashed in the middle of operating semaphore, the semaphore state is still safely recovered by later use, there is no waiter counter maintained by userland code. The main semaphore code is in libc and libthr only has some necessary stubs, this makes it possible that a non-threaded application can use semaphore without linking to thread library. Old semaphore implementation is kept libc to maintain binary compatibility. The kernel ksem API is no longer used in the new implemenation. Discussed on: threads@
* Work-around a race condition on ia64 while unlocking a contested lock.marcel2009-12-141-0/+3
| | | | | | | | The race condition is believed to be in UMTX_OP_MUTEX_WAKE. On ia64, we simply go to the kernel to unlock. The big question is why this is only a race condition on ia64... MFC after: 3 days
* Revert r199830 for now. Too many ports dlopen() libraries linked withkib2009-11-281-1/+1
| | | | libthr, but forgot to link main binary with it.
* Libthr cannot be dynamically loaded into the running process.kib2009-11-261-1/+1
| | | | | | | Mark it with -z nodlopen for now. Discussed with: jhb, kan MFC after: 3 weeks
* Current pselect(3) is implemented in usermode and thus vulnerable tokib2009-10-271-1/+3
| | | | | | | | | | | | | | | | | well-known race condition, which elimination was the reason for the function appearance in first place. If sigmask supplied as argument to pselect() enables a signal, the signal might be delivered before thread called select(2), causing lost wakeup. Reimplement pselect() in kernel, making change of sigmask and sleep atomic. Since signal shall be delivered to the usermode, but sigmask restored, set TDP_OLDMASK and save old mask in td_oldsigmask. The TDP_OLDMASK should be cleared by ast() in case signal was not gelivered during syscall execution. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* Implement _umtx_op_err() for ia64.marcel2009-10-243-1/+38
|
* 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
|
OpenPOWER on IntegriCloud