--- //depot/vendor/freebsd/src/sys/kern/vfs_bio.c 2008/03/22 09:16:15 +++ //depot/user/attilio/attilio_schedlock/kern/vfs_bio.c 2008/03/28 01:22:10 @@ -544,7 +544,6 @@ bp->b_qindex = QUEUE_EMPTY; bp->b_vflags = 0; bp->b_xflags = 0; - bp->b_waiters = 0; LIST_INIT(&bp->b_dep); BUF_LOCKINIT(bp); TAILQ_INSERT_TAIL(&bufqueues[QUEUE_EMPTY], bp, b_freelist); @@ -1183,7 +1182,7 @@ if (bp->b_bufsize) allocbuf(bp, 0); if (bp->b_vp) - (void) brelvp(bp); + brelvp(bp); } } @@ -1324,7 +1323,7 @@ if (bp->b_bufsize != 0) allocbuf(bp, 0); if (bp->b_vp != NULL) - (void) brelvp(bp); + brelvp(bp); } if (BUF_LOCKRECURSED(bp)) { @@ -1388,7 +1387,7 @@ if (bp->b_flags & B_DELWRI) bundirty(bp); if (bp->b_vp) - (void) brelvp(bp); + brelvp(bp); } /* @@ -1555,7 +1554,7 @@ bp->b_npages = 0; bp->b_flags &= ~B_VMIO; if (bp->b_vp) - (void) brelvp(bp); + brelvp(bp); } /* @@ -1693,7 +1692,6 @@ struct buf *nbp; int defrag = 0; int nqindex; - int waiters = 0; static int flushingbufs; /* @@ -1832,7 +1830,7 @@ vfs_vmio_release(bp); } if (bp->b_vp) - waiters = brelvp(bp); + brelvp(bp); } /* @@ -1901,7 +1899,7 @@ * Notify any waiters for the buffer lock about * identity change by freeing the buffer. */ - if (qindex == QUEUE_CLEAN && waiters > 0) { + if (qindex == QUEUE_CLEAN && BUF_LOCKWAITERS(bp)) { bp->b_flags |= B_INVAL; bfreekva(bp); brelse(bp); --- //depot/vendor/freebsd/src/sys/kern/vfs_subr.c 2008/03/24 04:26:30 +++ //depot/user/attilio/attilio_schedlock/kern/vfs_subr.c 2008/03/28 01:22:10 @@ -1527,12 +1527,11 @@ /* * Disassociate a buffer from a vnode. */ -int +void brelvp(struct buf *bp) { struct bufobj *bo; struct vnode *vp; - int waiters; CTR3(KTR_BUF, "brelvp(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(bp->b_vp != NULL, ("brelvp: NULL")); @@ -1557,11 +1556,8 @@ bp->b_flags &= ~B_NEEDSGIANT; bp->b_vp = NULL; bp->b_bufobj = NULL; - waiters = bp->b_waiters; BO_UNLOCK(bo); vdrop(vp); - - return (waiters); } /* --- //depot/vendor/freebsd/src/sys/sys/buf.h 2008/03/28 00:17:25 +++ //depot/user/attilio/attilio_schedlock/sys/buf.h 2008/03/28 01:24:06 @@ -139,7 +139,6 @@ void *b_fsprivate2; void *b_fsprivate3; int b_pin_count; - int b_waiters; /* (V) waiters counter */ }; #define b_object b_bufobj->bo_object @@ -267,38 +266,18 @@ * * Get a lock sleeping non-interruptably until it becomes available. */ -static __inline int -_BUF_LOCK(struct buf *bp, int locktype, struct mtx *interlock, char *file, - int line) -{ - int res; +#define BUF_LOCK(bp, locktype, interlock) \ + _lockmgr_args(&(bp)->b_lock, (locktype), (interlock), \ + LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, \ + LOCK_FILE, LOCK_LINE) - if (locktype & LK_INTERLOCK) - bp->b_waiters++; - res = _lockmgr_args(&bp->b_lock, locktype, interlock, LK_WMESG_DEFAULT, - LK_PRIO_DEFAULT, LK_TIMO_DEFAULT, file, line); - if (locktype & LK_INTERLOCK) - bp->b_waiters--; - return (res); -} - /* * Get a lock sleeping with specified interruptably and timeout. */ -static __inline int -_BUF_TIMELOCK(struct buf *bp, int locktype, struct mtx *interlock, - const char *wmesg, int catch, int timo, char *file, int line) -{ - int res; - - if (locktype & LK_INTERLOCK) - bp->b_waiters++; - res = _lockmgr_args(&bp->b_lock, locktype | LK_TIMELOCK, interlock, - wmesg, (PRIBIO + 4) | catch, timo, file, line); - if (locktype & LK_INTERLOCK) - bp->b_waiters--; - return (res); -} +#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \ + _lockmgr_args(&(bp)->b_lock, (locktype) | LK_TIMELOCK, \ + (interlock), (wmesg), (PRIBIO + 4) | (catch), (timo), \ + LOCK_FILE, LOCK_LINE) /* * Release a lock. Only the acquiring process may free the lock unless @@ -331,15 +310,6 @@ lockdestroy(&(bp)->b_lock) /* - * Use macro wrappers in order to exploit consumers tracking. - */ -#define BUF_LOCK(bp, locktype, interlock) \ - _BUF_LOCK((bp), (locktype), (interlock), LOCK_FILE, LOCK_LINE) -#define BUF_TIMELOCK(bp, locktype, interlock, wmesg, catch, timo) \ - _BUF_TIMELOCK((bp), (locktype), (interlock), (wmesg), (catch), \ - (timo), LOCK_FILE, LOCK_LINE) - -/* * Buffer lock assertions. */ #if defined(INVARIANTS) && defined(INVARIANT_SUPPORT) @@ -373,6 +343,12 @@ _lockmgr_disown(&(bp)->b_lock, LOCK_FILE, LOCK_LINE) #endif +/* + * Find out if the lock has waiters or not. + */ +#define BUF_LOCKWAITERS(bp) \ + lockmgr_waiters(&(bp)->b_lock) + #endif /* _KERNEL */ struct buf_queue_head { @@ -528,7 +504,7 @@ int vmapbuf(struct buf *); void vunmapbuf(struct buf *); void relpbuf(struct buf *, int *); -int brelvp(struct buf *); +void brelvp(struct buf *); void bgetvp(struct vnode *, struct buf *); void pbgetbo(struct bufobj *bo, struct buf *bp); void pbgetvp(struct vnode *, struct buf *); --- //depot/vendor/freebsd/src/sys/sys/lockmgr.h 2008/03/01 22:16:36 +++ //depot/user/attilio/attilio_schedlock/sys/lockmgr.h 2008/03/28 01:22:10 @@ -225,6 +225,8 @@ LOCK_FILE, LOCK_LINE) #define lockmgr_recursed(lkp) \ ((lkp)->lk_exclusivecount > 1) +#define lockmgr_waiters(lkp) \ + ((lkp)->lk_waitcount != 0) #ifdef INVARIANTS #define lockmgr_assert(lkp, what) \ _lockmgr_assert((lkp), (what), LOCK_FILE, LOCK_LINE)