tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kasserting non-ownership of locks

I would often like to kassert that I do *not* hold a lock, e.g. to
check that a vop correctly dropped its locks before some other vop
begins and lockdebug-panics.

Currently KASSERT(!mutex_owned(lock)) is not kosher, presumably
because if lock is a spin lock it might do the wrong thing -- fail
because some other CPU owns the spin lock.

I don't see any reason why KASSERT(!rw_write_held(rwlock)) or
KASSERT(VOP_ISLOCKED(vp) != LK_EXCLUSIVE) would do the wrong thing at
the moment: these both trigger iff the lock is held by curlwp.

1. Any reason why KASSERT(!mutex_owned(lock)) for an adaptive lock, or
KASSERT(!rw_write_held(rwlock)), or KASSERT(VOP_ISLOCKED(vp) !=
LK_EXCLUSIVE), would do the wrong thing?

2. If not, any objection to adding the following and using it for
locks known to be adaptive?

mutex_notowned(kmutex_t *lock)
        return !mutex_owned(lock);

Home | Main Index | Thread Index | Old Index