summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sx.c
Commit message (Collapse)AuthorAgeFilesLines
* Set the lock type equal to the lock name for now as all of the currentjhb2002-04-041-1/+1
| | | | sx locks don't use very specific lock names.
* - Add MTX_SYSINIT and SX_SYSINIT as macro glue for allowing sx and mtxarr2002-04-021-0/+8
| | | | | | | | | | locks to be able to setup a SYSINIT call. This helps in places where a lock is needed to protect some data, but the data is not truly associated with a subsystem that can properly initialize it's lock. The macros use the mtx_sysinit() and sx_sysinit() functions, respectively, as the handler argument to SYSINIT(). Reviewed by: alfred, jhb, smp@
* Invert the test of sx_xholder for SX_LOCKED. We need to warn if atanimura2002-01-181-3/+3
| | | | | | thread other than the curthread holds an sx. While I am here, break a line at the end of warning.
* Update to C99, s/__FUNCTION__/__func__/.obrien2001-12-101-3/+3
|
* Create a mutex pool API for short term leaf mutexes.dillon2001-11-131-28/+27
| | | | | Replace the manual mutex pool in kern_lock.c (lockmgr locks) with the new API. Replace the mutexes embedded in sxlocks with the new API.
* Fix this to actually compile in the !INVARIANTS case.jhb2001-10-241-0/+8
| | | | Reported by: Maxime Henrion <mux@qualys.com>
* Change the sx(9) assertion API to use a sx_assert() function similar tojhb2001-10-231-4/+43
| | | | mtx_assert(9) rather than several SX_ASSERT_* macros.
* The mtx_init() and sx_init() functions bzero'd locks before handing themjhb2001-10-201-1/+3
| | | | | | off to witness_init() making the check for double intializating a lock by testing the LO_INITIALIZED flag moot. Workaround this by checking the LO_INITIALIZED flag ourself before we bzero the lock structure.
* KSE Milestone 2julian2001-09-121-5/+5
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Use witness_upgrade/downgrade for sx_try_upgrade/downgrade.jhb2001-08-231-8/+6
|
* Clear the sx_xholder pointer when downgrading an exclusive lock.jhb2001-08-231-0/+1
|
* Add sx_try_upgrade() and sx_downgrade().jasone2001-08-131-0/+46
| | | | Submitted by: Alexander Kabaev <ak03@gte.com>
* - Add trylock variants of shared and exclusive locks.jhb2001-06-271-4/+42
| | | | | | | | | | | - The sx assertions don't actually need the internal sx mutex lock, so don't bother doing so. - Add a new assertion SX_ASSERT_LOCKED() that asserts that either a shared or exclusive lock should be held. This assertion should be used instead of SX_ASSERT_SLOCKED() in almost all cases. - Adjust some KASSERT()'s to include file and line information. - Use the new witness_assert() function in the WITNESS case for sx slock asserts to verify that the current thread actually owns a slock.
* - Move state about lock objects out of struct lock_object and into a newjhb2001-05-041-27/+3
| | | | | | | | | | | | | | | | | | | | struct lock_instance that is stored in the per-process and per-CPU lock lists. Previously, the lock lists just kept a pointer to each lock held. That pointer is now replaced by a lock instance which contains a pointer to the lock object, the file and line of the last acquisition of a lock, and various flags about a lock including its recursion count. - If we sleep while holding a sleepable lock, then mark that lock instance as having slept and ignore any lock order violations that occur while acquiring Giant when we wake up with slept locks. This is ok because of Giant's special nature. - Allow witness to differentiate between shared and exclusive locks and unlocks of a lock. Witness will now detect the case when a lock is acquired first in one mode and then in another. Mutexes are always locked and unlocked exclusively. Witness will also now detect the case where a process attempts to unlock a shared lock while holding an exclusive lock and vice versa. - Fix a bug in the lock list implementation where we used the wrong constant to detect the case where a lock list entry was full.
* Rework the witness code to work with sx locks as well as mutexes.jhb2001-03-281-10/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Introduce lock classes and lock objects. Each lock class specifies a name and set of flags (or properties) shared by all locks of a given type. Currently there are three lock classes: spin mutexes, sleep mutexes, and sx locks. A lock object specifies properties of an additional lock along with a lock name and all of the extra stuff needed to make witness work with a given lock. This abstract lock stuff is defined in sys/lock.h. The lockmgr constants, types, and prototypes have been moved to sys/lockmgr.h. For temporary backwards compatability, sys/lock.h includes sys/lockmgr.h. - Replace proc->p_spinlocks with a per-CPU list, PCPU(spinlocks), of spin locks held. By making this per-cpu, we do not have to jump through magic hoops to deal with sched_lock changing ownership during context switches. - Replace proc->p_heldmtx, formerly a list of held sleep mutexes, with proc->p_sleeplocks, which is a list of held sleep locks including sleep mutexes and sx locks. - Add helper macros for logging lock events via the KTR_LOCK KTR logging level so that the log messages are consistent. - Add some new flags that can be passed to mtx_init(): - MTX_NOWITNESS - specifies that this lock should be ignored by witness. This is used for the mutex that blocks a sx lock for example. - MTX_QUIET - this is not new, but you can pass this to mtx_init() now and no events will be logged for this lock, so that one doesn't have to change all the individual mtx_lock/unlock() operations. - All lock objects maintain an initialized flag. Use this flag to export a mtx_initialized() macro that can be safely called from drivers. Also, we on longer walk the all_mtx list if MUTEX_DEBUG is defined as witness performs the corresponding checks using the initialized flag. - The lock order reversal messages have been improved to output slightly more accurate file and line numbers.
* In order to avoid recursing on the backing mutex for sx locks in thejhb2001-03-061-2/+2
| | | | | | | INVARIANTS case, define the actual KASSERT() in _SX_ASSERT_[SX]LOCKED macros that are used in the sx code itself and convert the SX_ASSERT_[SX]LOCKED macros to simple wrappers that grab the mutex for the duration of the check.
* - Add sx_descr description member to sx lock structurebmilekic2001-03-061-6/+26
| | | | | | | | | | | | | | | | | - Add sx_xholder member to sx struct which is used for INVARIANTS-enabled assertions. It indicates the thread that presently owns the xlock. - Add some assertions to the sx lock code that will detect the fatal API abuse: xlock --> xlock xlock --> slock which now works thanks to sx_xholder. Notice that the remaining two problematic cases: slock --> xlock slock --> slock (a little less problematic, but still recursion) will need to be handled by witness eventually, as they are more involved. Reviewed by: jhb, jake, jasone
* Implement shared/exclusive locks.jasone2001-03-051-0/+160
Reviewed by: bmilekic, jake, jhb
OpenPOWER on IntegriCloud