diff options
author | attilio <attilio@FreeBSD.org> | 2008-03-01 19:47:50 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2008-03-01 19:47:50 +0000 |
commit | 0d873341312bfcbee292129a09cf72ab59e3ef38 (patch) | |
tree | aae2aca960881cff832f160d3cf4e0a5dcfa5d55 /sys/kern/kern_lock.c | |
parent | 354de8687f8df06279d4389e7437123d99d5ddb9 (diff) | |
download | FreeBSD-src-0d873341312bfcbee292129a09cf72ab59e3ef38.zip FreeBSD-src-0d873341312bfcbee292129a09cf72ab59e3ef38.tar.gz |
- Handle buffer lock waiters count directly in the buffer cache instead
than rely on the lockmgr support [1]:
* bump the waiters only if the interlock is held
* let brelvp() return the waiters count
* rely on brelvp() instead than BUF_LOCKWAITERS() in order to check
for the waiters number
- Remove a namespace pollution introduced recently with lockmgr.h
including lock.h by including lock.h directly in the consumers and
making it mandatory for using lockmgr.
- Modify flags accepted by lockinit():
* introduce LK_NOPROFILE which disables lock profiling for the
specified lockmgr
* introduce LK_QUIET which disables ktr tracing for the specified
lockmgr [2]
* disallow LK_SLEEPFAIL and LK_NOWAIT to be passed there so that it
can only be used on a per-instance basis
- Remove BUF_LOCKWAITERS() and lockwaiters() as they are no longer
used
This patch breaks KPI so __FreBSD_version will be bumped and manpages
updated by further commits. Additively, 'struct buf' changes results in
a disturbed ABI also.
[2] Really, currently there is no ktr tracing in the lockmgr, but it
will be added soon.
[1] Submitted by: kib
Tested by: pho, Andrea Barberio <insomniac at slackware dot it>
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r-- | sys/kern/kern_lock.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index d80a853..987b361 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -546,11 +546,14 @@ lockinit(lkp, prio, wmesg, timo, flags) { int iflags; + KASSERT((flags & (LK_NOWAIT | LK_SLEEPFAIL)) == 0, + ("%s: Invalid flags passed with mask 0x%x", __func__, + flags & LK_EXTFLG_MASK)); CTR5(KTR_LOCK, "lockinit(): lkp == %p, prio == %d, wmesg == \"%s\", " "timo == %d, flags = 0x%x\n", lkp, prio, wmesg, timo, flags); lkp->lk_interlock = mtx_pool_alloc(mtxpool_lockbuilder); - lkp->lk_flags = (flags & LK_EXTFLG_MASK) & ~(LK_NOWITNESS | LK_NODUP); + lkp->lk_flags = (flags & LK_EXTFLG_MASK) & ~(LK_FUNC_MASK); lkp->lk_sharecount = 0; lkp->lk_waitcount = 0; lkp->lk_exclusivecount = 0; @@ -561,8 +564,12 @@ lockinit(lkp, prio, wmesg, timo, flags) iflags = LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE; if (!(flags & LK_NODUP)) iflags |= LO_DUPOK; + if (flags & LK_NOPROFILE) + iflags |= LO_NOPROFILE; if (!(flags & LK_NOWITNESS)) iflags |= LO_WITNESS; + if (flags & LK_QUIET) + iflags |= LO_QUIET; #ifdef DEBUG_LOCKS stack_zero(&lkp->lk_stack); #endif @@ -644,23 +651,6 @@ lockstatus(lkp) } /* - * Determine the number of waiters on a lock. - */ -int -lockwaiters(lkp) - struct lock *lkp; -{ - int count; - - KASSERT((lkp->lk_flags & LK_DESTROYED) == 0, - ("%s: %p lockmgr is destroyed", __func__, lkp)); - mtx_lock(lkp->lk_interlock); - count = lkp->lk_waitcount; - mtx_unlock(lkp->lk_interlock); - return (count); -} - -/* * Print out information about state of a lock. Used by VOP_PRINT * routines to display status about contained locks. */ |