summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_sleepqueue.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-11-04 19:13:53 +0000
committerjhb <jhb@FreeBSD.org>2008-11-04 19:13:53 +0000
commitbfd6c884ce5ae926b3c5ac3e9fad8430de595c55 (patch)
treecd978da5af66906b85eb8b8f68739d466fc9bea6 /sys/kern/subr_sleepqueue.c
parent6c6f8c89e867271ab3baf15171419147ba85e088 (diff)
downloadFreeBSD-src-bfd6c884ce5ae926b3c5ac3e9fad8430de595c55.zip
FreeBSD-src-bfd6c884ce5ae926b3c5ac3e9fad8430de595c55.tar.gz
Don't bother calling setrunnable() and clearing the sleeping flag in
sleepq_resume_thread() if the thread isn't asleep.
Diffstat (limited to 'sys/kern/subr_sleepqueue.c')
-rw-r--r--sys/kern/subr_sleepqueue.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c
index 0f00a70..97511e0 100644
--- a/sys/kern/subr_sleepqueue.c
+++ b/sys/kern/subr_sleepqueue.c
@@ -680,22 +680,25 @@ sleepq_resume_thread(struct sleepqueue *sq, struct thread *td, int pri)
td->td_wchan = NULL;
td->td_flags &= ~TDF_SINTR;
- /*
- * Note that thread td might not be sleeping if it is running
- * sleepq_catch_signals() on another CPU or is blocked on
- * its proc lock to check signals. It doesn't hurt to clear
- * the sleeping flag if it isn't set though, so we just always
- * do it. However, we can't assert that it is set.
- */
CTR3(KTR_PROC, "sleepq_wakeup: thread %p (pid %ld, %s)",
(void *)td, (long)td->td_proc->p_pid, td->td_name);
- TD_CLR_SLEEPING(td);
/* Adjust priority if requested. */
MPASS(pri == 0 || (pri >= PRI_MIN && pri <= PRI_MAX));
if (pri != 0 && td->td_priority > pri)
sched_prio(td, pri);
- return (setrunnable(td));
+
+ /*
+ * Note that thread td might not be sleeping if it is running
+ * sleepq_catch_signals() on another CPU or is blocked on its
+ * proc lock to check signals. There's no need to mark the
+ * thread runnable in that case.
+ */
+ if (TD_IS_SLEEPING(td)) {
+ TD_CLR_SLEEPING(td);
+ return (setrunnable(td));
+ }
+ return (0);
}
#ifdef INVARIANTS
OpenPOWER on IntegriCloud