Index: sys/kern/kern_sx.c =================================================================== RCS file: /private/FreeBSD/src/sys/kern/kern_sx.c,v retrieving revision 1.21 diff -u -p -r1.21 kern_sx.c --- sys/kern/kern_sx.c 28 Jan 2004 20:39:57 -0000 1.21 +++ sys/kern/kern_sx.c 3 Feb 2004 18:12:41 -0000 @@ -344,6 +344,17 @@ _sx_assert(struct sx *sx, int what, cons sx->sx_object.lo_name, file, line); mtx_unlock(sx->sx_lock); break; + case SX_UNLOCKED: +#ifdef WITNESS + witness_assert(&sx->sx_object, what, file, line); +#else + mtx_lock(sx->sx_lock); + if (sx->sx_cnt != 0 && sx->sx_xholder == curthread) + printf("Lock %s locked @ %s:%d\n", + sx->sx_object.lo_name, file, line); + mtx_unlock(sx->sx_lock); +#endif + break; default: panic("Unknown sx lock assertion: %d @ %s:%d", what, file, line); Index: sys/sys/sx.h =================================================================== RCS file: /private/FreeBSD/src/sys/sys/sx.h,v retrieving revision 1.17 diff -u -p -r1.17 sx.h --- sys/sys/sx.h 2 Apr 2002 18:18:56 -0000 1.17 +++ sys/sys/sx.h 3 Feb 2004 18:05:08 -0000 @@ -85,6 +85,7 @@ struct sx_args { #define sx_downgrade(sx) _sx_downgrade((sx), LOCK_FILE, LOCK_LINE) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) +#define SX_UNLOCKED LA_UNLOCKED #define SX_LOCKED LA_LOCKED #define SX_SLOCKED LA_SLOCKED #define SX_XLOCKED LA_XLOCKED Index: share/man/man9/sx.9 =================================================================== RCS file: /private/FreeBSD/src/share/man/man9/sx.9,v retrieving revision 1.25 diff -u -p -r1.25 sx.9 --- share/man/man9/sx.9 1 Jan 2004 05:16:35 -0000 1.25 +++ share/man/man9/sx.9 3 Feb 2004 18:15:10 -0000 @@ -136,7 +136,7 @@ for the assertions specified in .Ar what and panics if they are not met. The following assertions are supported: -.Bl -tag -width ".Dv SX_XLOCKED" +.Bl -tag -width ".Dv SX_UNLOCKED" .It Dv SX_LOCKED Assert that the current thread has either a shared or an exclusive lock on the .Vt sx @@ -148,6 +148,11 @@ lock pointed to by the first argument. .It Dv SX_XLOCKED Assert that the current thread has an exclusive lock on the +.Vt sx +lock pointed to +by the first argument. +.It Dv SX_UNLOCKED +Assert that the current thread has no lock on the .Vt sx lock pointed to by the first argument.