Replace calls to WITNESS_SLEEP() and witness_list() with equivalent calls

to WITNESS_WARN().
This commit is contained in:
John Baldwin 2003-03-04 21:03:05 +00:00
parent 9b4982bfed
commit 263067951a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111883
24 changed files with 65 additions and 91 deletions

View File

@ -783,12 +783,8 @@ syscall(code, framep)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -1094,13 +1094,8 @@ syscall(frame)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -1094,13 +1094,8 @@ syscall(frame)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -904,12 +904,8 @@ syscall(int code, u_int64_t *args, struct trapframe *framep)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}
@ -1081,13 +1077,8 @@ ia32_syscall(struct trapframe *framep)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -199,7 +199,8 @@ cv_wait(struct cv *cvp, struct mtx *mp)
ktrcsw(1, 0);
#endif
CV_ASSERT(cvp, mp, td);
WITNESS_SLEEP(0, &mp->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object,
"Waiting on \"%s\"", cvp->cv_description);
WITNESS_SAVE(&mp->mtx_object, mp);
if (cold ) {
@ -255,7 +256,8 @@ cv_wait_sig(struct cv *cvp, struct mtx *mp)
ktrcsw(1, 0);
#endif
CV_ASSERT(cvp, mp, td);
WITNESS_SLEEP(0, &mp->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object,
"Waiting on \"%s\"", cvp->cv_description);
WITNESS_SAVE(&mp->mtx_object, mp);
if (cold || panicstr) {
@ -323,7 +325,8 @@ cv_timedwait(struct cv *cvp, struct mtx *mp, int timo)
ktrcsw(1, 0);
#endif
CV_ASSERT(cvp, mp, td);
WITNESS_SLEEP(0, &mp->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object,
"Waiting on \"%s\"", cvp->cv_description);
WITNESS_SAVE(&mp->mtx_object, mp);
if (cold || panicstr) {
@ -401,7 +404,8 @@ cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo)
ktrcsw(1, 0);
#endif
CV_ASSERT(cvp, mp, td);
WITNESS_SLEEP(0, &mp->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mp->mtx_object,
"Waiting on \"%s\"", cvp->cv_description);
WITNESS_SAVE(&mp->mtx_object, mp);
if (cold || panicstr) {

View File

@ -240,7 +240,9 @@ debuglockmgr(lkp, flags, interlkp, td, name, file, line)
}
if ((flags & (LK_NOWAIT|LK_RELEASE)) == 0)
WITNESS_SLEEP(1, &lkp->lk_interlock->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
&lkp->lk_interlock->mtx_object,
"Acquiring lockmgr lock \"%s\"", lkp->lk_wmesg);
if (panicstr != NULL) {
mtx_unlock(lkp->lk_interlock);

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -1648,7 +1648,8 @@ issignal(td)
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
WITNESS_SLEEP(1, &p->p_mtx.mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.mtx_object,
"Checking for signals");
for (;;) {
int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG);

View File

@ -149,7 +149,8 @@ msleep(ident, mtx, priority, wmesg, timo)
if (KTRPOINT(td, KTR_CSW))
ktrcsw(1, 0);
#endif
WITNESS_SLEEP(0, &mtx->mtx_object);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &mtx->mtx_object,
"Sleeping on \"%s\"", wmesg);
KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
("sleeping without a mutex"));
/*

View File

@ -1000,7 +1000,8 @@ sysctl_old_user(struct sysctl_req *req, const void *p, size_t l)
size_t i = 0;
if (req->lock == 1 && req->oldptr)
WITNESS_SLEEP(1, NULL);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"sysctl_old_user()");
if (req->oldptr) {
i = l;
if (req->oldlen <= req->oldidx)

View File

@ -1038,15 +1038,8 @@ mb_reclaim(void)
struct domain *dp;
struct protosw *pr;
/*
* XXX: Argh, we almost always trip here with witness turned on now-a-days
* XXX: because we often come in with Giant held. For now, there's no way
* XXX: to avoid this.
*/
#ifdef WITNESS
KASSERT(witness_list(curthread) == 0,
("mb_reclaim() called with locks held"));
#endif
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK | WARN_PANIC, NULL,
"mb_reclaim()");
mbstat.m_drain++; /* XXX: No consistency. */

View File

@ -157,10 +157,7 @@ ast(struct trapframe *framep)
CTR3(KTR_SYSC, "ast: thread %p (pid %d, %s)", td, p->p_pid,
p->p_comm);
KASSERT(TRAPF_USERMODE(framep), ("ast in kernel mode"));
#ifdef WITNESS
if (witness_list(td))
panic("Returning to user mode with mutex(s) held");
#endif
WITNESS_WARN(WARN_PANIC, NULL, "Returning to user mode");
mtx_assert(&Giant, MA_NOTOWNED);
mtx_assert(&sched_lock, MA_NOTOWNED);
td->td_frame = framep;

View File

@ -473,12 +473,8 @@ syscall(struct trapframe *frame)
*/
STOPEVENT(p, S_SCX, code);
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -473,12 +473,8 @@ syscall(struct trapframe *frame)
*/
STOPEVENT(p, S_SCX, code);
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -264,7 +264,7 @@ static int mac_policy_list_busy;
} while (0)
/*
* We manually invoke WITNESS_SLEEP() to allow Witness to generate
* We manually invoke WITNESS_WARN() to allow Witness to generate
* warnings even if we don't end up ever triggering the wait at
* run-time. The consumer of the exclusive interface must not hold
* any locks (other than potentially Giant) since we may sleep for
@ -273,7 +273,8 @@ static int mac_policy_list_busy;
* be made.
*/
#define MAC_POLICY_LIST_EXCLUSIVE() do { \
WITNESS_SLEEP(1, NULL); \
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \
"mac_policy_list_exclusive() at %s:%d", __FILE__, __LINE__);\
mtx_lock(&mac_policy_list_lock); \
while (mac_policy_list_busy != 0) \
cv_wait(&mac_policy_list_not_busy, \

View File

@ -629,12 +629,8 @@ syscall(struct trapframe *tf)
#ifdef DIAGNOSTIC
cred_free_thread(td);
#endif
#ifdef WITNESS
if (witness_list(td)) {
panic("system call %s returning with mutex(s) held\n",
syscallnames[code]);
}
#endif
WITNESS_WARN(WARN_PANIC, NULL, "System call %s returning",
syscallnames[code]);
mtx_assert(&sched_lock, MA_NOTOWNED);
mtx_assert(&Giant, MA_NOTOWNED);
}

View File

@ -1327,7 +1327,8 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
if (!(flags & M_NOWAIT)) {
KASSERT(curthread->td_intr_nesting_level == 0,
("malloc(M_WAITOK) in interrupt context"));
WITNESS_SLEEP(1, NULL);
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"malloc() of \"%s\"", zone->uz_name);
}
zalloc_restart: