Commit Graph

95 Commits

Author SHA1 Message Date
erh 76d8aa2c53 Fix call to simple_lock_assert_held() so builds with -DDEBUG work. 2006-03-31 06:01:07 +00:00
erh e4412d2162 Add simple_lock_assert_locked/simple_lock_assert_unlocked to provide additional
useful information when panic'ing because the assertion fails.
Use these to define the SCHED_ASSERT_LOCKED/SCHED_ASSERT_UNLOCKED macros.
2006-03-26 20:19:52 +00:00
erh 762add7da1 Check db_onpanic before dropping into the debugger on lock errors. 2006-03-16 00:52:32 +00:00
chs 0545b6e0cb changes for making DIAGNOSTIC not change the kernel ABI:
- for structure fields that are conditionally present,
   make those fields always present.
 - for functions which are conditionally inline, make them never inline.
 - remove some other functions which are conditionally defined but
   don't actually do anything anymore.
 - make a lock-debugging function conditional on only LOCKDEBUG.

as discussed on tech-kern some time back.
2005-12-27 04:06:45 +00:00
perry a2cd732268 Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete. 2005-12-24 19:12:23 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
chs 20b89dd47f default to simple_lock_debugger=1 with LOCKDEBUG. 2005-10-08 03:18:25 +00:00
blymn 92bd9a35e9 Fix function variable names shadowing global declarations. 2005-06-01 13:12:49 +00:00
christos 6639138da1 Now we can fix the volatile cast-aways.
Rename some shadowed variables while here.
2005-05-29 21:16:14 +00:00
perry da8abec863 nuke trailing whitespace 2005-02-26 21:34:55 +00:00
yamt 4dd708bfff a relatively lightweight implementation of kernel_lock. 2004-10-26 00:14:46 +00:00
yamt c0ebe301d7 don't reference kernel_lock directly. 2004-10-23 21:27:33 +00:00
yamt 1e4aff5d38 add missing wakeups in the cases of lock failure.
from Stephan Uphoff, FreeBSD PR/69964.

(http://www.freebsd.org/cgi/query-pr.cgi?pr=69964)
> The LK_WANT_EXCL and LK_WANT_UPGRADE bits act as mini-locks and can block
> other threads.
> Normally this is not a problem since the mini locks are upgraded to full loc
> and the release of the locks will unblock the other threads.
> However if a thread reset the bits without optaining a full lock
> other threads are not awoken.
> This can happens if obtaining the full lock fails because of a LK_SLEEPFAIL,
> or a signal (if lock priority includes PCATCH .. don't think this is used).
2004-08-04 10:37:08 +00:00
yamt 8b4f43c443 - revert a part of the previous which breaks LK_SPIN locks.
(reported by Nicolas Joly on current-users@)
- propagate the previous to spinlock_acquire_count.
2004-08-04 01:16:06 +00:00
yamt c602229c1a when acquiring an exclusive lock,
ensure that no one else have the same lock.
a patch from Stephan Uphoff, FreeBSD PR/69934.

(http://www.freebsd.org/cgi/query-pr.cgi?pr=69934)
>	Upgrading a lock does not play well together with acquiring
>	an exclusive lock and can lead to two threads being
>	granted exclusive access.
>
>	Problematic sequence:
>	Thread A acquires a previous unlocked lock in shared mode.
>	Thread B tries to acquire the same lock in exclusive mode
>	and blocks.
>	Thread A upgrades its lock - waking up thread B.
>	Thread B wakes up and also acquires the same lock as it only checks
>	if the lock is not shared or if someone wants to upgrade the lock
>	and not if someone already upgraded the lock to an exclusive lock.
2004-08-03 12:08:51 +00:00
yamt 2fd3d08b3d lockmgr: add a comment about LK_RETRY. 2004-05-31 09:05:10 +00:00
yamt 59ba83d898 lockmgr: assert that LK_RETRY is not specified. 2004-05-30 20:49:04 +00:00
hannken 8c21bc6224 Add ffs internal snapshots. Written by Marshall Kirk McKusick for FreeBSD.
- Not enabled by default. Needs kernel option FFS_SNAPSHOT.
- Change parameters of ffs_blkfree.
- Let the copy-on-write functions return an error so spec_strategy
    may fail if the copy-on-write fails.
- Change genfs_*lock*() to use vp->v_vnlock instead of &vp->v_lock.
- Add flag B_METAONLY to VOP_BALLOC to return indirect block buffer.
- Add a function ffs_checkfreefile needed for snapshot creation.
- Add special handling of snapshot files:
    Snapshots may not be opened for writing and the attributes are read-only.
    Use the mtime as the time this snapshot was taken.
    Deny mtime updates for snapshot files.
- Add function transferlockers to transfer any waiting processes from
  one lock to another.
- Add vfsop VFS_SNAPSHOT to take a snapshot and make it accessible through
  a vnode.
- Add snapshot support to ls, fsck_ffs and dump.

Welcome to 2.0F.

Approved by: Jason R. Thorpe <thorpej@netbsd.org>
2004-05-25 14:54:55 +00:00
yamt efc80878d1 use lockstatus() instead of L_BIGLOCK to check if we're holding a biglock.
fix PR/25595.
2004-05-18 11:59:11 +00:00
yamt b4831906b2 introduce LK_EXCLOTHER for lockstatus().
from FreeBSD, but a little differently.  instead of letting lockstatus()
take an additional thread argument, always use curlwp/curcpu.
2004-05-18 11:55:59 +00:00
wiz d20841bb64 Uppercase CPU, plural is CPUs. 2004-02-13 11:36:08 +00:00
hannken 10654a5c0a Fix last commit. The current spl was an implicit argument to the ACQUIRE
macro.  With help and approval from YAMAMOTO Takashi <yamt@netbsd.org>
2003-12-08 14:21:25 +00:00
yamt f9d2295ad0 turn ACQUIRE macro into a function by introducing new internal
flags, LK_SHARE_NONZERO and LK_WAIT_NONZERO.  from FreeBSD.
2003-11-23 08:57:16 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
pk 9ead24ac7a Use lock_printf() in SPINLOCK_SPINCHECK() and SLOCK_TRACE(). 2003-02-19 22:34:42 +00:00
pk 7f03dc8c13 _simple_lock(): revert to IPL at entry while spinning on the lock; raise
to spllock() again after we get it.
2003-01-19 14:40:55 +00:00
thorpej e0d8d366df Merge the nathanw_sa branch. 2003-01-18 10:06:22 +00:00
pk c70db21e38 lock_printf(): use vsnprintf/printf_nolog to avoid covertly using the system
log and thereby invoking scheduler code.
2003-01-15 23:11:05 +00:00
scw 0f91ed3dfa Quell uninitialised variable warnings. 2002-11-24 11:37:54 +00:00
perry 6858187df6 /*CONTCOND*/ while (0)'ed macros 2002-11-02 07:20:42 +00:00
fvdl 4244ef3b22 For INTERLOCK_ACQUIRE, s/splsched/spllock/. 2002-11-01 01:13:32 +00:00
provos 0f09ed48a5 remove trailing \n in panic(). approved perry. 2002-09-27 15:35:29 +00:00
chs 0e83d71253 print a stack trace in the "spinout" case too. 2002-09-14 21:42:42 +00:00
thorpej e839580821 Move kernel_lock manipulation info functions so that they will
show up in a profile.
2002-05-21 01:38:26 +00:00
enami af81fabf7c Remove #ifdef DIAGNOSTIC around panic(). It is better than NULL pointer
dereference.
2002-05-11 11:56:57 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
chs adb1a233b7 replace wakeup_one() with wakeup(). wakeup_one() can only be used if the
woken-up thread is guaranteed to pass the buck to the next guy before
going back to sleep, and the rest of the lockmgr() code doesn't do that.
from Bill Sommerfeld.  fixes PR 14097.
2001-09-29 21:27:49 +00:00
chs 039c1fd312 print a stack trace in more LOCKDEBUG cases.
add a blank line between complaints.
use TAILQ_FOREACH where appropriate.
2001-09-25 06:13:29 +00:00
sommerfeld acf40b361c Correct comment to match code 2001-09-22 22:36:30 +00:00
wiz daa5d204e4 synchron*, not sychron* 2001-07-08 17:41:14 +00:00
thorpej 31769952ca Add a simple_lock_only_held() LOCKDEBUG routine, which allows code
to assert that exactly zero or one (and a specific one) locks are
held.

From Bill Sommerfeld.
2001-06-05 04:38:08 +00:00
enami bda65c7816 Define local variable cpu_id only when either MULTIPROCESSOR or DIAGNOSTIC
is defined since it isn't used otherwise.
2001-05-01 04:30:04 +00:00
marcus b6240639a2 STDC cleanup: volatile needs to be cast away for lk_flags as well. 2001-04-27 00:05:13 +00:00
thorpej c24c3604b0 SPINLOCK_INTERLOCK_RELEASE_HOOK should actually be
SPINLOCK_SPIN_HOOK, so that we actually check for
pending IPIs on the Alpha more than once.  Also,
when we call alpha_ipi_process(), make sure to go
to splipi().
2001-04-20 22:58:39 +00:00
jmc ca607b87cf Default lock_printf to syslog rather than printf. Some of the lock debug checks
are done inside of wakeup which is holding the sched lock. Printf can cause
wakeup to get called again (pty redirection of console message) which will
panic with sched lock already held.

This isn't a long term fix as not being able to printf vs. sched lock should
be cleaned up better but this avoids continual panics with lockdebug running
and an xterm -C.
2000-12-24 23:56:24 +00:00
thorpej 113dd58233 Add a LOCKDEBUG check for a r/w spinlock spinning out of control.
Partially from Bill Sommerfeld.
2000-11-22 06:31:22 +00:00
thorpej 3075dec01a Allow machine dependent code to specify a hook to be run when a
spinlock's interlock is released.

Idea from Bill Sommerfeld.
2000-11-20 20:04:49 +00:00
sommerfeld 1cbfb08951 Fix !LOCKDEBUG && !DIAGNOSTIC case 2000-08-28 21:07:52 +00:00
sommerfeld bdc30aed03 Since the spinlock count is per-cpu, we don't need atomic operations
to update it, so don't bother with <machine/atomic.h>

Flush kernel_lock_release_all() and kernel_lock_acquire_count() (which
didn't do spinlock accounting correctly), and replace them with
spinlock_release_all() and spinlock_acquire_count().
2000-08-26 19:26:43 +00:00
thorpej fe036cae9a Fix a printf format (for Alpha). 2000-08-26 17:02:16 +00:00