- Don't do a WITNESS_SAVE() on the interlock if it is Giant in the condition
variable wait routines. DROP_GIANT() already manages that state in the Giant interlock case. - Assert that Giant is held when it is passed as a sleep interlock.
This commit is contained in:
parent
0dae32f2eb
commit
7d43ca696e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183352
@ -108,7 +108,6 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
|
||||
CV_ASSERT(cvp, lock, td);
|
||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
|
||||
"Waiting on \"%s\"", cvp->cv_description);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
class = LOCK_CLASS(lock);
|
||||
|
||||
if (cold || panicstr) {
|
||||
@ -124,12 +123,15 @@ _cv_wait(struct cv *cvp, struct lock_object *lock)
|
||||
sleepq_lock(cvp);
|
||||
|
||||
cvp->cv_waiters++;
|
||||
if (lock == &Giant.lock_object)
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
DROP_GIANT();
|
||||
|
||||
sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0);
|
||||
if (lock != &Giant.lock_object) {
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_release(cvp);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
lock_state = class->lc_unlock(lock);
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_lock(cvp);
|
||||
@ -225,7 +227,6 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
|
||||
CV_ASSERT(cvp, lock, td);
|
||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
|
||||
"Waiting on \"%s\"", cvp->cv_description);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
class = LOCK_CLASS(lock);
|
||||
|
||||
if (cold || panicstr) {
|
||||
@ -241,6 +242,8 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
|
||||
sleepq_lock(cvp);
|
||||
|
||||
cvp->cv_waiters++;
|
||||
if (lock == &Giant.lock_object)
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
DROP_GIANT();
|
||||
|
||||
sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR |
|
||||
@ -248,6 +251,7 @@ _cv_wait_sig(struct cv *cvp, struct lock_object *lock)
|
||||
if (lock != &Giant.lock_object) {
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_release(cvp);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
lock_state = class->lc_unlock(lock);
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_lock(cvp);
|
||||
@ -290,7 +294,6 @@ _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
CV_ASSERT(cvp, lock, td);
|
||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
|
||||
"Waiting on \"%s\"", cvp->cv_description);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
class = LOCK_CLASS(lock);
|
||||
|
||||
if (cold || panicstr) {
|
||||
@ -306,6 +309,8 @@ _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
sleepq_lock(cvp);
|
||||
|
||||
cvp->cv_waiters++;
|
||||
if (lock == &Giant.lock_object)
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
DROP_GIANT();
|
||||
|
||||
sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0);
|
||||
@ -313,6 +318,7 @@ _cv_timedwait(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
if (lock != &Giant.lock_object) {
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_release(cvp);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
lock_state = class->lc_unlock(lock);
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_lock(cvp);
|
||||
@ -358,7 +364,6 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
CV_ASSERT(cvp, lock, td);
|
||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
|
||||
"Waiting on \"%s\"", cvp->cv_description);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
class = LOCK_CLASS(lock);
|
||||
|
||||
if (cold || panicstr) {
|
||||
@ -374,6 +379,8 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
sleepq_lock(cvp);
|
||||
|
||||
cvp->cv_waiters++;
|
||||
if (lock == &Giant.lock_object)
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
DROP_GIANT();
|
||||
|
||||
sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR |
|
||||
@ -382,6 +389,7 @@ _cv_timedwait_sig(struct cv *cvp, struct lock_object *lock, int timo)
|
||||
if (lock != &Giant.lock_object) {
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_release(cvp);
|
||||
WITNESS_SAVE(lock, lock_witness);
|
||||
lock_state = class->lc_unlock(lock);
|
||||
if (class->lc_flags & LC_SLEEPABLE)
|
||||
sleepq_lock(cvp);
|
||||
|
@ -181,6 +181,8 @@ _sleep(void *ident, struct lock_object *lock, int priority,
|
||||
CTR5(KTR_PROC, "sleep: thread %ld (pid %ld, %s) on %s (%p)",
|
||||
td->td_tid, p->p_pid, td->td_name, wmesg, ident);
|
||||
|
||||
if (lock == &Giant.lock_object)
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
DROP_GIANT();
|
||||
if (lock != NULL && lock != &Giant.lock_object &&
|
||||
!(class->lc_flags & LC_SLEEPABLE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user