#
b6b7fd3e |
| 28-Nov-2007 |
Jason Evans <jasone@FreeBSD.org> |
Fix pointer dereferencing problems in _pthread_mutex_init_calloc_cb() that were obscured by pseudo-opaque pthreads API pointer casting.
|
#
e1636e1f |
| 27-Nov-2007 |
Jason Evans <jasone@FreeBSD.org> |
Add _pthread_mutex_init_calloc_cb() to libthr and libkse, so that malloc(3) (part of libc) can use pthreads mutexes without causing infinite recursion during initialization.
|
#
9e1ddd5f |
| 21-Nov-2007 |
David Xu <davidxu@FreeBSD.org> |
Convert ceiling type to unsigned integer before comparing, fix compiler warnings.
|
#
56b45d90 |
| 31-Oct-2007 |
David Xu <davidxu@FreeBSD.org> |
Avoid doing adaptive spinning for priority protected mutex, current implementation always does lock in kernel.
|
#
55f18e07 |
| 31-Oct-2007 |
David Xu <davidxu@FreeBSD.org> |
Don't do adaptive spinning if it is running on UP kernel.
|
#
e8ef3c28 |
| 31-Oct-2007 |
David Xu <davidxu@FreeBSD.org> |
Restore revision 1.55, the kris's adaptive mutex type.
|
#
83941f79 |
| 30-Oct-2007 |
Kris Kennaway <kris@FreeBSD.org> |
Adaptive mutexes should have the same deadlock detection properties that default (errorcheck) mutexes do.
Noticed by: davidxu
|
#
7416cdab |
| 30-Oct-2007 |
David Xu <davidxu@FreeBSD.org> |
Add my recent work of adaptive spin mutex code. Use two environments variable to tune pthread mutex performance: 1. LIBPTHREAD_SPINLOOPS If a pthread mutex is being locked by another thread, this en
Add my recent work of adaptive spin mutex code. Use two environments variable to tune pthread mutex performance: 1. LIBPTHREAD_SPINLOOPS If a pthread mutex is being locked by another thread, this environment variable sets total number of spin loops before the current thread sleeps in kernel, this saves a syscall overhead if the mutex will be unlocked very soon (well written application code). 2. LIBPTHREAD_YIELDLOOPS If a pthread mutex is being locked by other threads, this environment variable sets total number of sched_yield() loops before the currrent thread sleeps in kernel. if a pthread mutex is locked, the current thread gives up cpu, but will not sleep in kernel, this means, current thread does not set contention bit in mutex, but let lock owner to run again if the owner is on kernel's run queue, and when lock owner unlocks the mutex, it does not need to enter kernel and do lots of work to resume mutex waiters, in some cases, this saves lots of syscall overheads for mutex owner.
In my practice, sometimes LIBPTHREAD_YIELDLOOPS can massively improve performance than LIBPTHREAD_SPINLOOPS, this depends on application. These two environments are global to all pthread mutex, there is no interface to set them for each pthread mutex, the default values are zero, this means spinning is turned off by default.
show more ...
|
#
2017a7cd |
| 29-Oct-2007 |
Kris Kennaway <kris@FreeBSD.org> |
Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. This is also implemented in glibc and is used by a number of existing applications (mysql, firefox, etc).
This mutex type is a defaul
Add a new "non-portable" mutex type, PTHREAD_MUTEX_ADAPTIVE_NP. This is also implemented in glibc and is used by a number of existing applications (mysql, firefox, etc).
This mutex type is a default mutex with the additional property that it spins briefly when attempting to acquire a contested lock, doing trylock operations in userland before entering the kernel to block if eventually unsuccessful.
The expectation is that applications requesting this mutex type know that the mutex is likely to be only held for very brief periods, so it is faster to spin in userland and probably succeed in acquiring the mutex, than to enter the kernel and sleep, only to be woken up almost immediately. This can help significantly in certain cases when pthread mutexes are heavily contended and held for brief durations (such as mysql).
Spin up to 200 times before entering the kernel, which represents only a few us on modern CPUs. No performance degradation was observed with this value and it is sufficient to avoid a large performance drop in mysql performance in the heavily contended pthread mutex case.
The libkse implementation is a NOP.
Reviewed by: jeff MFC after: 3 days
show more ...
|
#
00784f8b |
| 09-May-2007 |
David Xu <davidxu@FreeBSD.org> |
backout experimental adaptive spinning mutex for product use.
|
Revision tags: release/6.2.0_cvs, release/6.2.0 |
|
#
03779e5c |
| 05-Jan-2007 |
David Xu <davidxu@FreeBSD.org> |
Insert mutex at tail if it has highest ceiling.
|
#
da20a63d |
| 05-Jan-2007 |
David Xu <davidxu@FreeBSD.org> |
Oops, don't corrupt the list.
|
#
5470bb56 |
| 05-Jan-2007 |
David Xu <davidxu@FreeBSD.org> |
Check if the PP mutex is recursive, if we have already locked it, place the mutex in right order sorted by priority ceiling.
|
#
842a092b |
| 20-Dec-2006 |
David Xu <davidxu@FreeBSD.org> |
Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, use it as a default spin cycle count.
|
#
8a8178c0 |
| 14-Dec-2006 |
David Xu <davidxu@FreeBSD.org> |
Create inline function _thr_umutex_trylock2 to only try one atomic operation, if it is failed, we call syscall directly, this saves one atomic operation per lock contention.
|
#
58c7bab3 |
| 11-Nov-2006 |
David Xu <davidxu@FreeBSD.org> |
Move code calculating new inherited priority into single function.
|
#
ddaf6689 |
| 08-Sep-2006 |
David Xu <davidxu@FreeBSD.org> |
Use return value of _thr_umutex_lock instead of using zero.
|
#
8ab9d78b |
| 28-Aug-2006 |
David Xu <davidxu@FreeBSD.org> |
Use umutex APIs to implement pthread_mutex, member pp_mutexq is added into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex, no real mutex code is changed, the mutex locking and u
Use umutex APIs to implement pthread_mutex, member pp_mutexq is added into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex, no real mutex code is changed, the mutex locking and unlocking code should has same performance as before.
show more ...
|
#
065dbdc1 |
| 08-Aug-2006 |
David Xu <davidxu@FreeBSD.org> |
Axe unused member field.
|
#
da845843 |
| 17-Jul-2006 |
Xin LI <delphij@FreeBSD.org> |
Unexpand two TAILQ_FOREACH_SAFE cases.
Ok'ed by: davidxu
|
#
b971a730 |
| 02-Jun-2006 |
David Xu <davidxu@FreeBSD.org> |
Remove unused member field m_queue.
|
Revision tags: release/5.5.0_cvs, release/5.5.0, release/6.1.0_cvs, release/6.1.0 |
|
#
a9794459 |
| 08-Apr-2006 |
David Xu <davidxu@FreeBSD.org> |
Do not check validity of timeout if a mutex can be acquired immediately. Completly drop recursive mutex in pthread_cond_wait and restore recursive after resumption. Reorganize code to make gcc to gen
Do not check validity of timeout if a mutex can be acquired immediately. Completly drop recursive mutex in pthread_cond_wait and restore recursive after resumption. Reorganize code to make gcc to generate better code.
show more ...
|
#
37a6356b |
| 04-Apr-2006 |
David Xu <davidxu@FreeBSD.org> |
WARNS level 4 cleanup.
|
#
9ad4b644 |
| 28-Mar-2006 |
David Xu <davidxu@FreeBSD.org> |
Remove priority mutex code because it does not work correctly, to make it work, turnstile like mechanism to support priority propagating and other realtime scheduling options in kernel should be avai
Remove priority mutex code because it does not work correctly, to make it work, turnstile like mechanism to support priority propagating and other realtime scheduling options in kernel should be available to userland mutex, for the moment, I just want to make libthr be simple and efficient thread library.
Discussed with: deischen, julian
show more ...
|
#
7b8797d3 |
| 28-Feb-2006 |
David Xu <davidxu@FreeBSD.org> |
Reimplement mutex_init to get rid of compile warning.
|