summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Print correct file name and line number in mtx_assert().jasone2001-01-221-6/+6
| | | | Noticed by: jake
* Move most of sys/mutex.h into kern/kern_mutex.c, thereby making the mutexjasone2001-01-211-75/+388
| | | | | | | | | | | inline functions non-inlined. Hide parts of the mutex implementation that should not be exposed. Make sure that WITNESS code is not executed during boot until the mutexes are fully initialized by SI_SUB_MUTEX (the original motivation for this commit). Submitted by: peter
* Make the order of the static initializer for all_mtx match the order ofjasone2001-01-211-2/+2
| | | | | | fields in struct mtx. Found by: jake
* Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutexjasone2001-01-211-29/+81
| | | | | | | | initialization until after malloc() is safe to call, then iterate through all mutexes and complete their initialization. This change is necessary in order to avoid some circular bootstrapping dependencies.
* - Make npx_intr INTR_MPSAFE and move acquiring Giant into thejake2001-01-201-20/+0
| | | | | | function itself. - Remove a hack to allow acquiring Giant from the npx asm trap vector.
* Implement MTX_RECURSE flag for mtx_init().bmilekic2001-01-191-20/+55
| | | | | | | | | | | | | | | | | | | All calls to mtx_init() for mutexes that recurse must now include the MTX_RECURSE bit in the flag argument variable. This change is in preparation for an upcoming (further) mutex API cleanup. The witness code will call panic() if a lock is found to recurse but the MTX_RECURSE bit was not set during the lock's initialization. The old MTX_RECURSE "state" bit (in mtx_lock) has been renamed to MTX_RECURSED, which is more appropriate given its meaning. The following locks have been made "recursive," thus far: eventhandler, Giant, callout, sched_lock, possibly some others declared in the architecture-specific code, all of the network card driver locks in pci/, as well as some other locks in dev/ stuff that I've found to be recursive. Reviewed by: jhb
* Use PCPU_GET, PCPU_PTR and PCPU_SET to access all per-cpu variablesjake2001-01-101-3/+5
| | | | other then curproc.
* - Add a new flag MTX_QUIET that can be passed to the various mtx_*jhb2000-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.
* - Add code to detect if a system call returns with locks other than Giantjake2000-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.
* Oops, the witness mutex is a spin lock, so use MTX_SPIN in the call tojhb2000-12-121-1/+1
| | | | | mtx_init(). Since the witness code ignores its internal mutex, this doesn't result in any functional change.
* Convert more malloc+bzero to malloc+M_ZERO.dwmalone2000-12-081-2/+2
| | | | | Submitted by: josh@zipperup.org Submitted by: Robert Drehmel <robd@gmx.net>
* Split the WITNESS and MUTEX_DEBUG options apart so that WITNESS does notjhb2000-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.
* Fix up priority propagation:jhb2000-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).
* Set p_mtxname when blocking on a mutex and clear it when waking up.jhb2000-11-291-0/+2
|
* Use an atomic operation with an appropriate memory barrier when releasingjhb2000-11-291-1/+2
| | | | | a contested sleep mutex in the case that at least two processes are blocked on the contested mutex.
* The sched_lock mutex goes after the sio mutex in the locking order sincejhb2000-11-291-1/+1
| | | | | a software interrupt can be scheduled in the sio interrupt handler while the sio mutex is held.
* Save the line number and filename of the last mtx_enter operation forjhb2000-11-291-0/+8
| | | | spin locks. We already do this for sleep locks.
* Move the #define of _KERN_MUTEX_C_ so that it's before any system headersalfred2000-11-261-1/+6
| | | | | | | are included. System headers can include sys/mutex.h and then certain macros do not get defined. Reviewed by: jake
* Add uidinfo hash and uidinfo struct to the witness order list.jake2000-11-261-0/+1
|
* - Protect the callout wheel with a separate spin mutex, callout_lock.jake2000-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
* - Split the run queue and sleep queue linkage, so that a processjake2000-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
* Don't release and acquire Giant in mi_switch(). Instead, release andjhb2000-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
* Include the right headers to get the DDB #define and the db_active variable.jhb2000-11-151-0/+3
|
* Declare the 'witness_spin_check' properly as a per-CPU variable in thejhb2000-11-151-4/+0
| | | | non-SMP case.
* Don't perform witness checks in witness_enter() during a panic.jhb2000-11-151-1/+1
|
* Minor whitespace nit in a comment.jhb2000-11-101-1/+1
|
* - Use MUTEX_DECLARE() and MTX_COLD for the WITNESS code's internal mutex sojhb2000-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.
* Quite some warnings.jhb2000-10-251-3/+3
|
* Propogate the 'const'ness of mutex descriptions to the witness code tojhb2000-10-201-3/+3
| | | | quiet warnings.
* Actually enable the witness code if the WITNESS kernel option is enabled.jhb2000-10-201-5/+1
|
* Doh. Fix a 64-bit-ism by using uintptr_t for a temporary lock variablejhb2000-10-201-1/+1
| | | | instead of int.
* - Make the mutex code almost completely machine independent. This greatlyjhb2000-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().
* Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, justjhb2000-09-141-60/+61
| | | | | | use struct mtx, struct witness, and struct witness_blessed. Requested by: bde
* Style cleanups. No functional changes.jasone2000-09-091-8/+6
|
* Add file and line arguments to WITNESS_ENTER() and WITNESS_EXIT, sincejasone2000-09-091-3/+3
| | | | | | __FILE__ and __LINE__ don't get expanded usefully in inline functions. Add const to all witness*() arguments that are filenames.
* Rename mtx_enter(), mtx_try_enter(), and mtx_exit() and wrap them with cppjasone2000-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.
* Major update to the way synchronization is done in the kernel. Highlightsjasone2000-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
OpenPOWER on IntegriCloud