aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_mutex.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variablesJake Burkholder2001-01-101-3/+5
| | | | | | | other then curproc. Notes: svn path=/head/; revision=70861
* - Add a new flag MTX_QUIET that can be passed to the various mtx_*John Baldwin2000-12-131-40/+65
| | | | | | | | | | | | | functions. If this flag is set, then no KTR log messages are issued. This is useful for blocking excessive logging, such as with the internal mutex used by the witness code. - Use MTX_QUIET on all of the mtx_enter/exit operations on the internal mutex used by the witness code. - If we are in a panic, don't do witness checks in witness_enter(), witness_exit(), and witness_try_enter(), just return. Notes: svn path=/head/; revision=69998
* - Add code to detect if a system call returns with locks other than GiantJake Burkholder2000-12-121-1/+6
| | | | | | | | | | | | held and panic if so (conditional on witness). - Change witness_list to return the number of locks held so this is easier. - Add kern/syscalls.c to the kernel build if witness is defined so that the panic message can contain the name of the offending system call. - Add assertions that Giant and sched_lock are not held when returning from a system call, which were missing for alpha and ia64. Notes: svn path=/head/; revision=69881
* Oops, the witness mutex is a spin lock, so use MTX_SPIN in the call toJohn Baldwin2000-12-121-1/+1
| | | | | | | | mtx_init(). Since the witness code ignores its internal mutex, this doesn't result in any functional change. Notes: svn path=/head/; revision=69879
* Convert more malloc+bzero to malloc+M_ZERO.David Malone2000-12-081-2/+2
| | | | | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net> Notes: svn path=/head/; revision=69781
* Split the WITNESS and MUTEX_DEBUG options apart so that WITNESS does notJohn Baldwin2000-12-011-9/+12
| | | | | | | | | | depend on MUTEX_DEBUG. The MUTEX_DEBUG option turns on extra assertions and checks to verify that mutexes themselves are implemented properly. The WITNESS option uses extra checks and diagnostics to verify that other code is using mutexes properly. Notes: svn path=/head/; revision=69429
* Fix up priority propagation:John Baldwin2000-11-301-24/+60
| | | | | | | | | | - Use a better test for determining when a process is running. - Convert some checks to assertions. - Remove unnecessary tests. - Save the priority before acquiring a mutex rather than in msleep(9). Notes: svn path=/head/; revision=69376
* Set p_mtxname when blocking on a mutex and clear it when waking up.John Baldwin2000-11-291-0/+2
| | | | Notes: svn path=/head/; revision=69369
* Use an atomic operation with an appropriate memory barrier when releasingJohn Baldwin2000-11-291-1/+2
| | | | | | | | a contested sleep mutex in the case that at least two processes are blocked on the contested mutex. Notes: svn path=/head/; revision=69363
* The sched_lock mutex goes after the sio mutex in the locking order sinceJohn Baldwin2000-11-291-1/+1
| | | | | | | | a software interrupt can be scheduled in the sio interrupt handler while the sio mutex is held. Notes: svn path=/head/; revision=69362
* Save the line number and filename of the last mtx_enter operation forJohn Baldwin2000-11-291-0/+8
| | | | | | | spin locks. We already do this for sleep locks. Notes: svn path=/head/; revision=69361
* Move the #define of _KERN_MUTEX_C_ so that it's before any system headersAlfred Perlstein2000-11-261-1/+6
| | | | | | | | | | are included. System headers can include sys/mutex.h and then certain macros do not get defined. Reviewed by: jake Notes: svn path=/head/; revision=69215
* Add uidinfo hash and uidinfo struct to the witness order list.Jake Burkholder2000-11-261-0/+1
| | | | Notes: svn path=/head/; revision=69208
* - Protect the callout wheel with a separate spin mutex, callout_lock.Jake Burkholder2000-11-191-0/+1
| | | | | | | | | | | | | | - Use the mutex in hardclock to ensure no races between it and softclock. - Make softclock be INTR_MPSAFE and provide a flag, CALLOUT_MPSAFE, which specifies that a callout handler does not need giant. There is still no way to set this flag when regstering a callout. Reviewed by: -smp@, jlemon Notes: svn path=/head/; revision=68889
* - Split the run queue and sleep queue linkage, so that a processJake Burkholder2000-11-171-0/+1
| | | | | | | | | | | | may block on a mutex while on the sleep queue without corrupting it. - Move dropping of Giant to after the acquire of sched_lock. Tested by: John Hay <jhay@icomtek.csir.co.za> jhb Notes: svn path=/head/; revision=68862
* Don't release and acquire Giant in mi_switch(). Instead, release andJohn Baldwin2000-11-161-39/+4
| | | | | | | | | | | acquire Giant as needed in functions that call mi_switch(). The releases need to be done outside of the sched_lock to avoid potential deadlocks from trying to acquire Giant while interrupts are disabled. Submitted by: witness Notes: svn path=/head/; revision=68808
* Include the right headers to get the DDB #define and the db_active variable.John Baldwin2000-11-151-0/+3
| | | | Notes: svn path=/head/; revision=68790
* Declare the 'witness_spin_check' properly as a per-CPU variable in theJohn Baldwin2000-11-151-4/+0
| | | | | | | non-SMP case. Notes: svn path=/head/; revision=68786
* Don't perform witness checks in witness_enter() during a panic.John Baldwin2000-11-151-1/+1
| | | | Notes: svn path=/head/; revision=68785
* Minor whitespace nit in a comment.John Baldwin2000-11-101-1/+1
| | | | Notes: svn path=/head/; revision=68582
* - Use MUTEX_DECLARE() and MTX_COLD for the WITNESS code's internal mutex soJohn Baldwin2000-10-271-56/+38
| | | | | | | | | | | | | | | | | | | it can function before malloc(9) is up and running. - Add two new options WITNESS_DDB and WITNESS_SKIPSPIN. If WITNESS_SKIPSPIN is enabled, then spin mutexes are ignored by the WITNESS code. If WITNESS_DDB is turned on and DDB is compiled into the kernel, then the kernel will drop into DDB when either a lock hierarchy violation occurs or mutexes are held when going to sleep. - Add some new sysctls: debug.witness_ddb is a read-write sysctl that corresponds to WITNESS_DDB. The kernel option merely changes the default value to on at boot. debug.witness_skipspin is a read-only sysctl that one can use to determine if the kernel was compiled with WITNESS_SKIPSPIN. - Wipe out the BSD/OS-specific lock order lists. We get to build our own lists now as we add mutexes to the kernel. Notes: svn path=/head/; revision=67676
* Quite some warnings.John Baldwin2000-10-251-3/+3
| | | | Notes: svn path=/head/; revision=67548
* Propogate the 'const'ness of mutex descriptions to the witness code toJohn Baldwin2000-10-201-3/+3
| | | | | | | quiet warnings. Notes: svn path=/head/; revision=67404
* Actually enable the witness code if the WITNESS kernel option is enabled.John Baldwin2000-10-201-5/+1
| | | | Notes: svn path=/head/; revision=67401
* Doh. Fix a 64-bit-ism by using uintptr_t for a temporary lock variableJohn Baldwin2000-10-201-1/+1
| | | | | | | instead of int. Notes: svn path=/head/; revision=67396
* - Make the mutex code almost completely machine independent. This greatlyJohn Baldwin2000-10-201-10/+595
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reducues the maintenance load for the mutex code. The only MD portions of the mutex code are in machine/mutex.h now, which include the assembly macros for handling mutexes as well as optionally overriding the mutex micro-operations. For example, we use optimized micro-ops on the x86 platform #ifndef I386_CPU. - Change the behavior of the SMP_DEBUG kernel option. In the new code, mtx_assert() only depends on INVARIANTS, allowing other kernel developers to have working mutex assertiions without having to include all of the mutex debugging code. The SMP_DEBUG kernel option has been renamed to MUTEX_DEBUG and now just controls extra mutex debugging code. - Abolish the ugly mtx_f hack. Instead, we dynamically allocate seperate mtx_debug structures on the fly in mtx_init, except for mutexes that are initiated very early in the boot process. These mutexes are declared using a special MUTEX_DECLARE() macro, and use a new flag MTX_COLD when calling mtx_init. This is still somewhat hackish, but it is less evil than the mtx_f filler struct, and the mtx struct is now the same size with and without mutex debugging code. - Add some micro-micro-operation macros for doing the actual atomic operations on the mutex mtx_lock field to make it easier for other archs to override/optimize mutex ops if needed. These new tiny ops also clean up the code in some places by replacing long atomic operation function calls that spanned 2-3 lines with a short 1-line macro call. - Don't call mi_switch() from mtx_enter_hard() when we block while trying to obtain a sleep mutex. Calling mi_switch() would bogusly release Giant before switching to the next process. Instead, inline most of the code from mi_switch() in the mtx_enter_hard() function. Note that when we finally kill Giant we can back this out and go back to calling mi_switch(). Notes: svn path=/head/; revision=67352
* Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, justJohn Baldwin2000-09-141-60/+61
| | | | | | | | | use struct mtx, struct witness, and struct witness_blessed. Requested by: bde Notes: svn path=/head/; revision=65856
* Style cleanups. No functional changes.Jason Evans2000-09-091-8/+6
| | | | Notes: svn path=/head/; revision=65651
* Add file and line arguments to WITNESS_ENTER() and WITNESS_EXIT, sinceJason Evans2000-09-091-3/+3
| | | | | | | | | __FILE__ and __LINE__ don't get expanded usefully in inline functions. Add const to all witness*() arguments that are filenames. Notes: svn path=/head/; revision=65650
* Rename mtx_enter(), mtx_try_enter(), and mtx_exit() and wrap them with cppJason Evans2000-09-081-4/+4
| | | | | | | | | | | macros that expand to pass filename and line number information. This is necessary since we're using inline functions instead of macros now. Add const to the filename pointers passed througout the mtx and witness code. Notes: svn path=/head/; revision=65624
* Major update to the way synchronization is done in the kernel. HighlightsJason Evans2000-09-071-0/+799
include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh Notes: svn path=/head/; revision=65557