Add in assertions to ensure that we always call msleep or mawait with
either a timeout or a held mutex to detect unprotected infinite sleeps that can easily lead to deadlock. Submitted by: alfred
This commit is contained in:
parent
f73cf22ade
commit
b516d2f5e1
@ -383,6 +383,8 @@ msleep(ident, mtx, priority, wmesg, timo)
|
||||
ktrcsw(p->p_tracep, 1, 0);
|
||||
#endif
|
||||
WITNESS_SLEEP(0, &mtx->mtx_object);
|
||||
KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
|
||||
("sleeping without a mutex"));
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (cold || panicstr) {
|
||||
/*
|
||||
@ -574,6 +576,8 @@ mawait(struct mtx *mtx, int priority, int timo)
|
||||
WITNESS_SAVE_DECL(mtx);
|
||||
|
||||
WITNESS_SLEEP(0, &mtx->mtx_object);
|
||||
KASSERT(timo > 0 || mtx_owned(&Giant) || mtx != NULL,
|
||||
("sleeping without a mutex"));
|
||||
mtx_lock_spin(&sched_lock);
|
||||
DROP_GIANT_NOSWITCH();
|
||||
if (mtx != NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user