summaryrefslogtreecommitdiff
path: root/sys/kern/kern_lock.c
Commit message (Collapse)AuthorAgeFilesLines
* Add missing includes of sys/ktr.h.John Baldwin2001-10-111-0/+1
| | | | Notes: svn path=/head/; revision=84812
* Malloc mutexes pre-zero'd as random garbage (including 0xdeadcode) myJohn Baldwin2001-10-101-1/+1
| | | | | | | trigget the check to make sure we don't initalize a mutex twice. Notes: svn path=/head/; revision=84781
* Fix locking on td_flags for TDF_DEADLKTREAT. If the comments in the codeJohn Baldwin2001-09-131-8/+4
| | | | | | | | are true that curthread can change during this function, then this flag needs to become a KSE flag, not a thread flag. Notes: svn path=/head/; revision=83420
* KSE Milestone 2Julian Elischer2001-09-121-14/+14
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=83366
* If we've panic'd already, then just bail in lockmgr rather than blocking orJohn Baldwin2001-08-101-0/+5
| | | | | | | possibly panic'ing again. Notes: svn path=/head/; revision=81506
* Instead of asserting that a mutex is not still locked after unlocking it,Alfred Perlstein2001-04-281-1/+1
| | | | | | | | | assert that the mutex is owned and not recursed prior to unlocking it. This should give a clearer diagnostic when a programming error is caught. Notes: svn path=/head/; revision=76100
* Assert that when using an interlock mutex it is not recursed when lockmgr()Alfred Perlstein2001-04-201-1/+3
| | | | | | | | | is called. Ok'd by: jhb Notes: svn path=/head/; revision=75740
* convert if/panic -> KASSERT, explain what triggered the assertionAlfred Perlstein2001-04-131-2/+4
| | | | Notes: svn path=/head/; revision=75472
* Fix a precedence bug. ! has higher precedence than &.Jake Burkholder2001-04-081-1/+1
| | | | Notes: svn path=/head/; revision=75304
* Proc locking.John Baldwin2001-02-091-14/+10
| | | | Notes: svn path=/head/; revision=72227
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* Convert all simplelocks to mutexes and remove the simplelock implementations.Jason Evans2001-01-241-120/+2
| | | | Notes: svn path=/head/; revision=71576
* Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutexJason Evans2001-01-211-3/+3
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=71320
* Use msleep instead of mtx_exit; tsleep; mtx_enter, which is not safe.Jake Burkholder2000-12-011-6/+3
| | | | Notes: svn path=/head/; revision=69432
* - machine/mutex.h -> sys/mutex.hJohn Baldwin2000-10-201-5/+4
| | | | | | | | - The initial lock_mtx mutex used in the lockmgr code is initialized very early, so use MUTEX_DECLARE() and MTX_COLD. Notes: svn path=/head/; revision=67353
* For lockmgr mutex protection, use an array of mutexes that are allocatedJason Evans2000-10-121-22/+79
| | | | | | | | | | | | and initialized during boot. This avoids bloating sizeof(struct lock). As a side effect, it is no longer necessary to enforce the assumtion that lockinit()/lockdestroy() calls are paired, so the LK_VALID flag has been removed. Idea taken from: BSD/OS. Notes: svn path=/head/; revision=67046
* Convert lockmgr locks from using simple locks to using mutexes.Jason Evans2000-10-041-17/+47
| | | | | | | | | Add lockdestroy() and appropriate invocations, which corresponds to lockinit() and must be called to clean up after a lockmgr lock is no longer needed. Notes: svn path=/head/; revision=66615
* Move MAXCPU from machine/smp.h to machine/param.h to fix breakagePaul Saab2000-09-231-2/+2
| | | | | | | | with !SMP kernels. Also, replace NCPUS with MAXCPU since they are redundant. Notes: svn path=/head/; revision=66296
* Make LINT compile.Poul-Henning Kamp2000-09-161-2/+0
| | | | Notes: svn path=/head/; revision=65932
* Eliminate the undocumented, experimental, non-delivering and highlyPoul-Henning Kamp2000-03-161-16/+0
| | | | | | | dangerous MAX_PERF option. Notes: svn path=/head/; revision=58132
* Lock reporting and assertion changes.Eivind Eklund1999-12-111-4/+8
| | | | | | | | | | | | | | | | | | * lockstatus() and VOP_ISLOCKED() gets a new process argument and a new return value: LK_EXCLOTHER, when the lock is held exclusively by another process. * The ASSERT_VOP_(UN)LOCKED family is extended to use what this gives them * Extend the vnode_if.src format to allow more exact specification than locked/unlocked. This commit should not do any semantic changes unless you are using DEBUG_VFS_LOCKS. Discussed with: grog, mch, peter, phk Reviewed by: peter Notes: svn path=/head/; revision=54444
* Correct a locking error in apause: It should always holdAlan Cox1999-11-111-14/+16
| | | | | | | | | | | | the simple lock when it returns. Also, eliminate spinning on a uniprocessor. It's pointless. Submitted by: bde, Assar Westerlund <assar@sics.se> Notes: svn path=/head/; revision=53090
* Fix process p_locks accounting. Conversions of the owner to LK_KERNPROCMatthew Dillon1999-09-271-2/+5
| | | | | | | | | caused p_locks to be improperly accounted. Submitted by: Tor.Egge@fast.no Notes: svn path=/head/; revision=51702
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* When requesting an exclusive lock with LK_NOWAIT, do not panicKirk McKusick1999-06-281-5/+7
| | | | | | | | | | if LK_RECURSIVE is not set, as we will simply return that the lock is busy and not actually deadlock. This allows processes to use polling locks against buffers that they may already hold exclusively locked. Notes: svn path=/head/; revision=48301
* Convert buffer locking from using the B_BUSY and B_WANTED flags to usingKirk McKusick1999-06-261-2/+18
| | | | | | | | | | lockmgr locks. This commit should be functionally equivalent to the old semantics. That is, all buffer locking is done with LK_EXCLUSIVE requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will be done in future commits. Notes: svn path=/head/; revision=48225
* fix breakage for alphas.Julian Elischer1999-03-151-2/+2
| | | | | | | Submitted by: Andrew Gallatin <gallatin@cs.duke.edu> Notes: svn path=/head/; revision=44772
* This solves a deadlock that can occur when read()ing into a file-mmap()Julian Elischer1999-03-121-3/+24
| | | | | | | | | | | | | | | space. When doing this, it is possible to for another process to attempt to get an exclusive lock on the vnode and deadlock the mmap/read combination when the uiomove() call tries to obtain a second shared lock on the vnode. There is still a potential deadlock situation with write()/mmap(). Submitted by: Matt Dillon <dillon@freebsd.org> Reviewed by: Luoqi Chen <luoqi@freebsd.org> Delimmitted by tag PRE_MATT_MMAP_LOCK and POST_MATT_MMAP_LOCK in kern/kern_lock.c kern/kern_subr.c Notes: svn path=/head/; revision=44681
* Add 'options DEBUG_LOCKS', which stores extra information in structEivind Eklund1999-01-201-1/+25
| | | | | | | | | | | lock, and add some macros and function parameters to make sure that the information get to the point where it can be put in the lock structure. While I'm here, add DEBUG_VFS_LOCKS to LINT. Notes: svn path=/head/; revision=42900
* KNFize, by bde.Eivind Eklund1999-01-101-1/+2
| | | | Notes: svn path=/head/; revision=42453
* Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT asEivind Eklund1999-01-081-9/+2
| | | | | | | | | | | | discussed on -hackers. Introduce 'KASSERT(assertion, ("panic message", args))' for simple check + panic. Reviewed by: msmith Notes: svn path=/head/; revision=42408
* Staticize.Eivind Eklund1998-11-261-2/+2
| | | | Notes: svn path=/head/; revision=41362
* Really finish supporting compiling with `gcc -ansi'.Bruce Evans1998-04-171-2/+2
| | | | Notes: svn path=/head/; revision=35242
* Some kern_lock code improvements. Add missing wakeup, and enableJohn Dyson1998-03-071-10/+43
| | | | | | | disabling some diagnostics when memory or speed is at a premium. Notes: svn path=/head/; revision=34194
* Include SIMPLELOCK_DEBUG functions even if SMP if compiling LINT; giveEivind Eklund1998-02-111-2/+6
| | | | | | | an error for the combination if _not_ compiling LINT. Notes: svn path=/head/; revision=33232
* Back out DIAGNOSTIC changes.Eivind Eklund1998-02-061-3/+1
| | | | Notes: svn path=/head/; revision=33134
* Turn DIAGNOSTIC into a new-style option.Eivind Eklund1998-02-041-1/+3
| | | | Notes: svn path=/head/; revision=33108
* Remove a bunch of variables which were unused both in GENERIC and LINT.Poul-Henning Kamp1997-11-071-3/+1
| | | | | | | Found by: -Wunused Notes: svn path=/head/; revision=31016
* Removed unused #includes.Bruce Evans1997-10-281-5/+1
| | | | Notes: svn path=/head/; revision=30813
* Change the M_NAMEI allocations to use the zone allocator. This changeJohn Dyson1997-09-211-77/+85
| | | | | | | | | | | plus the previous changes to use the zone allocator decrease the useage of malloc by half. The Zone allocator will be upgradeable to be able to use per CPU-pools, and has more intelligent usage of SPLs. Additionally, it has reasonable stats gathering capabilities, while making most calls inline. Notes: svn path=/head/; revision=29653
* typo in comment.Poul-Henning Kamp1997-08-221-2/+2
| | | | Notes: svn path=/head/; revision=28569
* Allow lockmgr to work without a current process. Disallowing thatJohn Dyson1997-08-191-3/+4
| | | | | | | was a mistake in the lockmgr rewrite. Notes: svn path=/head/; revision=28393
* Added includes of smp.h for SMP.Steve Passe1997-08-181-1/+5
| | | | | | | This eliminates a bazillion warnings about implicit s_lock & friends. Notes: svn path=/head/; revision=28349
* Fix kern_lock so that it will work. Additionally, clean-up some of theJohn Dyson1997-08-181-132/+144
| | | | | | | | | | | VM systems usage of the kernel lock (lockmgr) code. This is a first pass implementation, and is expected to evolve as needed. The API for the lock manager code has not changed, but the underlying implementation has changed significantly. This change should not materially affect our current SMP or UP code without non-standard parameters being used. Notes: svn path=/head/; revision=28345
* pushed down "volatility" of simplelock to actual int inside the struct.Steve Passe1997-08-041-5/+5
| | | | | | | Submitted by: bde@zeta.org.au, smp@csn.net Notes: svn path=/head/; revision=27894
* Fixed commented-out Lite2 sysctl debug.lockpausetime.Bruce Evans1997-04-011-5/+6
| | | | | | | Removed unused #includes. Notes: svn path=/head/; revision=24480
* Add missing $Id$Peter Wemm1997-03-251-0/+1
| | | | | | | Note; the RCS file has also been reconstructed to have a CSRG vendor branch. Notes: svn path=/head/; revision=24277
* Replace original rev 1.3; Author: bde; Date: 1997/02/25 17:24:43;Peter Wemm1997-03-251-3/+2
| | | | | | | | Fix counting of simplelocks in SIMPLELOCK_DEBUG Fix style regression Notes: svn path=/head/; revision=24274
* Replace original rev 1.2; Author: mpp; Date: 1997/02/12 06:52:30Peter Wemm1997-03-251-0/+1
| | | | | | | Add missing #include <sys/systm.h> Notes: svn path=/head/; revision=24273
* Replace original revision 1.1; Author dyson; Date: 1997/02/10 02:28:15Peter Wemm1997-03-251-8/+14
| | | | | | | | | | Changes from Lite2: - DEBUG -> SIMPLELOCK_DEBUG - cosmetic fixes - bzero of lock at init time -> explicit init of members. Notes: svn path=/head/; revision=24271