summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_rwlock.c
Commit message (Collapse)AuthorAgeFilesLines
...
* - Simplify the #ifdef's for adaptive mutexes and rwlocks by conditionallyjhb2007-03-221-23/+29
| | | | | defining a macro earlier in the file. - Add NO_ADAPTIVE_RWLOCKS option to disable adaptive spinning for rwlocks.
* Rename the 'mtx_object', 'rw_object', and 'sx_object' members of mutexes,jhb2007-03-211-72/+72
| | | | rwlocks, and sx locks to 'lock_object'.
* Print readers count as unsigned in ddb 'show lock'.jhb2007-03-131-2/+2
| | | | Submitted by: attilio
* Fix a typo.jhb2007-03-121-1/+1
|
* Add two new function pointers 'lc_lock' and 'lc_unlock' to lock classes.jhb2007-03-091-0/+33
| | | | | | | | | | | | | These functions are intended to be used to drop a lock and then reacquire it when doing an sleep such as msleep(9). Both functions accept a 'struct lock_object *' as their first parameter. The 'lc_unlock' function returns an integer that is then passed as the second paramter to the subsequent 'lc_lock' function. This can be used to communicate state. For example, sx locks and rwlocks use this to indicate if the lock was share/read locked vs exclusive/write locked. Currently, spin mutexes and lockmgr locks do not provide working lc_lock and lc_unlock functions.
* Use C99-style struct member initialization for lock classes.jhb2007-03-091-3/+3
|
* Fix some nits in lock profiling for rwlocks:jhb2007-03-071-6/+9
| | | | | | | | | - Properly note when a read lock is released. - Always note when we contest on a read lock. - Only note success of obtaining read locks for the first reader to match the behavior of sx(9). Reviewed by: kmacy
* Further improvements to LOCK_PROFILING:kmacy2007-02-271-2/+2
| | | | | | | | | | | | - Fix missing initialization in kern_rwlock.c causing bogus times to be collected - Move updates to the lock hash to after the lock is released for spin mutexes, sleep mutexes, and sx locks - Add new kernel build option LOCK_PROFILE_FAST - only update lock profiling statistics when an acquisition is contended. This reduces the overhead of LOCK_PROFILING to increasing system time by 20%-25% which on "make -j8 kernel-toolchain" on a dual woodcrest is unmeasurable in terms of wall-clock time. Contrast this to enabling lock profiling without LOCK_PROFILE_FAST and I see a 5x-6x slowdown in wall-clock time.
* Add rw_wowned() interface to rwlock(9), allowing a kernel thread torwatson2007-02-261-0/+7
| | | | | | | | determine if it holds an exclusive rwlock reference or not. This is non-ideal, but recursion scenarios in the network stack currently require it. Approved by: jhb
* general LOCK_PROFILING cleanupkmacy2007-02-261-11/+3
| | | | | | | | | | | | - only collect timestamps when a lock is contested - this reduces the overhead of collecting profiles from 20x to 5x - remove unused function from subr_lock.c - generalize cnt_hold and cnt_lock statistics to be kept for all locks - NOTE: rwlock profiling generates invalid statistics (and most likely always has) someone familiar with that should review
* track lock class name in a way that doesn't break WITNESSkmacy2006-11-131-1/+1
|
* MUTEX_PROFILING has been generalized to LOCK_PROFILING. We now profilekmacy2006-11-111-2/+20
| | | | | | | | | | | wait (time waited to acquire) and hold times for *all* kernel locks. If the architecture has a system synchronized TSC, the profiling code will use that - thereby minimizing profiling overhead. Large chunks of profiling code have been moved out of line, the overhead measured on the T1 for when it is compiled in but not enabled is < 1%. Approved by: scottl (standing in for mentor rwatson) Reviewed by: des and jhb
* Adjust td_locks for non-spin mutexes, rwlocks, and sx locks so that it isjhb2006-07-271-0/+4
| | | | | | | | a count of all non-spin locks, not just lockmgr locks. This can give us a much cheaper way to see if we have any locks held (such as when returning to userland via userret()) without requiring WITNESS. MFC after: 1 week
* Implement rw_try_upgrade() and rw_downgrade(). rw_try_upgrade() makes ajhb2006-04-191-2/+133
| | | | | single attempt at upgrading a read lock to a write lock, and rw_downgrade() converts curthread's write lock into a read lock.
* 'owner' is not used without SMP. Fix kernel build for such kernelwkoszek2006-04-181-0/+4
| | | | | | configurations. Approved by: jhb
* Adaptively spin before blocking on the turnstile if an rwlock is writejhb2006-04-181-7/+88
| | | | | | | | | | | | | | locked. In general the adaptive spinning is similar to the same code for mutexes with some extra trickiness in rw_wunlock_hard(). Specifically, even though both wait bits might be set and we might have a turnstile with at least one waiting thread, there might not be any threads blocked on the queue we are not waking up (they might all be spinning), and we should only preserve the waiting flag for the queue we aren't waking up if there are in fact threads blocked on that queue. Secondly, there might not be any threads blocked on the queue we have chosen to waken threads from (there might only be threads blocked on the other queue and the threads for this queue are all spinning) in which case we disown the turnstile instead of doing a braodcast and unpend.
* - Add a rw_wowner() macro that just returns the owner of a write lock andjhb2006-04-171-26/+38
| | | | | | | | use it in places that only care about the write owner instead of rw_owner() as a baby step towards limited read-lock owner. - Tidy the code that sets the WAITER flag bits to not duplicate a test around the atomic operation and the KTR trace in both of the lock functions.
* Fix another compile problem. If I find any more, this file is going in thescottl2006-02-011-1/+1
| | | | Attic until it is properly fixed.
* Regroup order of operations to better reflect what was probably intended.scottl2006-01-301-3/+3
| | | | Submitted by: Peter Jeremy
* Take a stab at making this compile when WITNESS is not defined. gcc can'tscottl2006-01-291-4/+4
| | | | | figure out the order of operations at line 519, and neither can I, but this is my best guess. Also correct a number of typos and syntax errors.
* Unbreak on archs where %d doesn't print uintptr_t arithmetic.mlaier2006-01-291-1/+2
|
* Add a basic reader/writer lock implementation to the kernel. Thisjhb2006-01-271-0/+587
implementation is by no means perfect as far as some of the algorithms that it uses and the fact that it is missing some functionality (try locks and upgrades/downgrades are not there yet), however it does seem to work in my local testing. There is more detail in the comments in the code, but the short version follows. A reader/writer lock is very much like a regular mutex: it cannot be held across a voluntary sleep; it can be acquired in an interrupt thread; if the lock is held by a writer then the priority of any threads that block on the lock will be lent to the owner; the simple case lock operations all are done in a single atomic op. It also shares some similiarities with sx locks: it supports reader/writer semantics (multiple readers, but single writers); readers are allowed to recurse, but writers are not. We can extend this implementation further by either improving algorithms or adding new functionality, but this should at least give us a base to work with now. Reviewed by: arch (in theory) Tested on: i386 (4 cpu box with a kernel module that used 4 threads that randomly chose between read locks and write locks that ran w/o panicing for over a day solid. It usually panic'd within a few seconds when there were bugs during testing. :) The kernel module source is available on request.)
OpenPOWER on IntegriCloud