Commit Graph

26 Commits

Author SHA1 Message Date
sommerfeld 39db0e9c7e Three MULTIPROCESSOR + LOCKDEBUG fixes:
1) fix typo preventing compilation (missing comma).
2) in SLOCK_WHERE, display cpu number in the MP case.
3) the folowing race condition was observed in _simple_lock:
	cpu 1 releases lock,
	cpu 0 grabs lock
 	cpu 1 sees it's already locked.
	cpu 1 sees that lock_holder== "cpu 1"
	cpu 1 assumes that it already holds it and barfs.
	cpu 0 sets lock_holder == "cpu 0"
Fix: set lock_holder to LK_NOCPU in _simple_unlock().
2000-02-09 16:46:09 +00:00
thorpej 8d4e2a9293 Make it possible to direct LOCKDEBUG messages to syslog only. 1999-08-27 01:14:38 +00:00
thorpej cca4496da7 Use cpuid_t and cpu_number(). 1999-08-10 21:10:20 +00:00
thorpej cb41412726 Fix a thinko in draining of spin locks: bump waitcount in the spin case,
too.  Remove some needless code duplication by adding a "drain" argument
to the ACQUIRE() macro (compiler can [and does] optimize the constant
conditional).
1999-07-28 19:29:39 +00:00
mellon a976011fcf - Correct the definition of the COUNT macro so that it takes the same
number of arguments when compiled without DIAGNOSTIC as with.
1999-07-28 01:59:46 +00:00
thorpej 6390046137 Improve the LOCKDEBUG code:
- Now compatible with MULTIPROCESSOR (requires other changes not yet
  committed, but which will be later today).
- In addition to tracking simple locks, track exclusive spin locks.
- Count spin locks like we do sleep locks (in the cpu_info for this
  CPU).
- Lock debug lists are now TAILQs, so as to make the locking order
  more obvious when dumping the list.

Also, some suggestions from Bill Sommerfeld:
- SIMPLELOCK_LOCKED and SIMPLELOCK_UNLOCKED constants, which may be
  defined in <machine/lock.h> (default to 1 and 0, respectively).  This
  makes it easier to support architectures which use test-and-clear
  rather than test-and-set.
- Add __attribute__((__aligned__)) to the `lock_data' member of the
  simplelock structure.  This makes it easier to support architectures
  which can only perform atomic operations on very-well-aligned memory
  locations.  NOTE: This changes the size of struct simplelock, and
  will cause a version bump.
1999-07-27 21:29:15 +00:00
thorpej c0e24db820 Use wakeup_one() for waking up sleep lock sleepers. 1999-07-26 23:02:53 +00:00
thorpej 50f9f26fe1 Add a spin lock mode to the lock manager. Provides a read/write
spin lock facility.  Some code and ideas from Ross Harvey.
1999-07-25 06:24:22 +00:00
chs fce05250f9 more cleanup:
remove simplelockrecurse, lockpausetime and PAUSE():
none of these serve any purpose anymore.
in the LOCKDEBUG functions, expand the splhigh() region to
cover the entire function.  without this there can still be races.
1999-07-19 03:21:11 +00:00
sommerfe c0d15c5c7c Count lockmgr locks held by process if LOCKDEBUG || DIAGNOSTIC.
(previously, it was just under LOCKDEBUG).
1999-05-04 15:58:53 +00:00
sommerfe f1a508e354 Prevent deadlock cited in PR4629 from crashing the system. (copyout
and system call now just return EFAULT).  A complete fix will
presumably have to wait for UBC and/or for vnode locking protocols to
be revamped to allow use of shared locks.
1999-03-25 00:20:35 +00:00
fvdl 080ad305ff Recursive locks were previously only available with LK_CANRECURSE. This
could be done in one of 2 ways:

	* call lk_init with LK_CANRECURSE, resulting in a lock that
 	  always can be used recursively.
	* call lockmgr with LK_CANRECURSE, meaning that it's ok if this
	  lock is already held by us.

Sometimes we need a locking type that says: take this lock now, exclusively,
but while I am holding it, I may go through a code path which could attempt
to get the lock again, and which is unaware that the lock might already
be taken.  Implement LK_SETRECURSE for this purpose. Assume that locks and
unlocks come in matching pairs (they should), and check for this 'level'
using SETRECURSE locks.
1999-02-28 14:09:15 +00:00
chs 33c042b6a2 print a little more info in simple_lock_freecheck(). 1999-01-22 07:55:17 +00:00
bouyer c2912048fc Cosmectic change in a panic(), so that the panic string printed by savecore
has more meaning.
1998-12-02 10:41:01 +00:00
chs 61458d7dfa LOCKDEBUG enhancements for non-MP:
keep a list of locked locks.
use this to print where the lock was locked
when we either go to sleep with a lock held
or try to free a locked lock.
1998-11-04 06:19:55 +00:00
pk c65c55af6f Disable the daft PAUSE() macro, which manages to skip all the relevant
code in lockmgr() most of the time. This a no doubt a case of Bad Coding Style.
1998-10-14 09:41:21 +00:00
thorpej ac0d359bcb Initialize the CPU ID in the simplelock. 1998-09-29 07:29:53 +00:00
thorpej 0c11d72456 Key off MULTIPROCESSOR, not NCPUS > 1. Pull in <machine/lock.h> if
MULTIPROCESSOR is defined, and rely on it to define the simple lock
operations.
1998-09-24 22:30:11 +00:00
perry 275d1554aa Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) ->  memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
   bcmp(x, y, z) ->  memcmp(x, y, z)
  bzero(x, y)    ->  memset(x, 0, y)
1998-08-04 04:03:10 +00:00
thorpej ad7a87400a defopt LOCKDEBUG 1998-05-20 01:32:29 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
chs d7d62b7ad3 snazzier LOCKDEBUG code. 1998-02-07 02:14:04 +00:00
mycroft 7f35228e7e Make wmesg arguments to various functions const. 1997-10-09 12:49:44 +00:00
fvdl 6eecd789e6 There appear to be spinlock bugs in the VM code. They are not a problem
now, as we're always one on CPU (they will be later, though). With DEBUG,
they cause a lot of output, so DEBUG -> LOCKDEBUG for now.
1997-07-06 22:51:59 +00:00
fvdl 8f8988628d Add NetBSD RCS Id, and a few minor changes to make it compile. 1997-07-06 12:35:33 +00:00
fvdl f93a04da47 Import Lite2 locking code 1997-07-06 12:19:53 +00:00