aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/sched_4bsd.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2019-05-08 16:30:38 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2019-05-08 16:30:38 +0000
commitac97da9ad8e5419e5c0926314f4502e1a75180e5 (patch)
treefc3101f04de16207c75f236a5226c865439b15cc /sys/kern/sched_4bsd.c
parent2b03b6bd45f35010536162ad2b5fa4ef5f27144f (diff)
downloadsrc-ac97da9ad8e5419e5c0926314f4502e1a75180e5.tar.gz
src-ac97da9ad8e5419e5c0926314f4502e1a75180e5.zip
Reduce umtx-related work on exec and exit
- there is no need to take the process lock to iterate the thread list after single-threading is enforced - typically there are no mutexes to clean up (testable without taking the global umtx lock) - typically there is no need to adjust the priority (testable without taking thread lock) Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20160
Notes
Notes: svn path=/head/; revision=347355
Diffstat (limited to 'sys/kern/sched_4bsd.c')
-rw-r--r--sys/kern/sched_4bsd.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index a85356107930..c53b838f8db6 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -930,6 +930,27 @@ sched_lend_user_prio(struct thread *td, u_char prio)
td->td_flags |= TDF_NEEDRESCHED;
}
+/*
+ * Like the above but first check if there is anything to do.
+ */
+void
+sched_lend_user_prio_cond(struct thread *td, u_char prio)
+{
+
+ if (td->td_lend_user_pri != prio)
+ goto lend;
+ if (td->td_user_pri != min(prio, td->td_base_user_pri))
+ goto lend;
+ if (td->td_priority >= td->td_user_pri)
+ goto lend;
+ return;
+
+lend:
+ thread_lock(td);
+ sched_lend_user_prio(td, prio);
+ thread_unlock(td);
+}
+
void
sched_sleep(struct thread *td, int pri)
{