diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2019-05-08 16:30:38 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2019-05-08 16:30:38 +0000 |
commit | ac97da9ad8e5419e5c0926314f4502e1a75180e5 (patch) | |
tree | fc3101f04de16207c75f236a5226c865439b15cc /sys/kern/sched_ule.c | |
parent | 2b03b6bd45f35010536162ad2b5fa4ef5f27144f (diff) | |
download | src-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_ule.c')
-rw-r--r-- | sys/kern/sched_ule.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index b20604d11274..e11907427da2 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -1861,6 +1861,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); +} + #ifdef SMP /* * This tdq is about to idle. Try to steal a thread from another CPU before |