Commit Graph

15 Commits

Author SHA1 Message Date
Attilio Rao
917c07ca1d MFC r197445:
Let fall down in the hard path (thus handling shared waiters wakeup
correctly) for the shared waiters also in the rwlock held in shared mode
as well, fixing possible deadlocks.

Please note that this is a special condition as we want this fix in
before RC2 as we assume it is critical and so it has been handled
as an instant-merge.  For the STABLE_7 branch, 1 week before the MFC
is assumed.

Approved by:	re (kib)
2009-09-24 08:35:17 +00:00
David Xu
7de1ecef2d Add two commands to _umtx_op system call to allow a simple mutex to be
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
2008-06-24 07:32:12 +00:00
David Xu
8d6a11a070 Use UMTX_OP_WAIT_UINT_PRIVATE and UMTX_OP_WAKE_PRIVATE to save
time in kernel(avoid VM lookup).
2008-04-29 03:58:18 +00:00
David Xu
8bf1a48cb3 Replace userland rwlock with a pure kernel based rwlock, the new
implementation does not switch pointers when it resumes waiters.

Asked by: jeff
2008-04-02 04:32:31 +00:00
David Xu
6fdfcacb4a Remove umtx_t definition, use type long directly, add wrapper function
_thr_umtx_wait_uint() for umtx operation UMTX_OP_WAIT_UINT, use the
function in semaphore operations, this fixed compiler warnings.
2007-11-21 05:21:58 +00:00
David Xu
842a092b74 Check environment variable PTHREAD_ADAPTIVE_SPIN, if it is set, use
it as a default spin cycle count.
2006-12-20 04:43:34 +00:00
David Xu
8a8178c010 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.
2006-12-14 13:22:02 +00:00
David Xu
670b44d65a Add _thr_ucond_init(). 2006-12-05 06:53:44 +00:00
David Xu
2bd2c90703 Use kernel provided userspace condition variable to implement pthread
condition variable.
2006-12-04 14:20:41 +00:00
David Xu
8042f26d52 o Make _thr_umutex_init a function.
o Eliminate unused parameter for some functions.
o Convert type of first parameter to void * for _thr_umtx_wait
  and _thr_umtx_wake.
2006-10-13 22:31:00 +00:00
David Xu
bddd24cd9c Replace internal usage of struct umtx with umutex which can supports
real-time if we want, no functionality is changed.
2006-09-06 04:04:10 +00:00
David Xu
cf13ecda6a Add umutex APIs. 2006-08-28 04:47:27 +00:00
David Xu
8429e73473 Hide umtx API symbols as well. 2005-12-21 03:53:29 +00:00
David Xu
2ff77b9220 Cast to uintptr_t to avoid compiler warning, it was broken by
the recent atomic_ptr() change.
2005-07-28 03:34:54 +00:00
David Xu
a091d823ad Import my recent 1:1 threading working. some features improved includes:
1. fast simple type mutex.
 2. __thread tls works.
 3. asynchronous cancellation works ( using signal ).
 4. thread synchronization is fully based on umtx, mainly, condition
    variable and other synchronization objects were rewritten by using
    umtx directly. those objects can be shared between processes via
    shared memory, it has to change ABI which does not happen yet.
 5. default stack size is increased to 1M on 32 bits platform, 2M for
    64 bits platform.
As the result, some mysql super-smack benchmarks show performance is
improved massivly.

Okayed by: jeff, mtm, rwatson, scottl
2005-04-02 01:20:00 +00:00