From ac97da9ad8e5419e5c0926314f4502e1a75180e5 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 8 May 2019 16:30:38 +0000 Subject: 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 --- sys/kern/sched_4bsd.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sys/kern/sched_4bsd.c') 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) { -- cgit v1.2.3