diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2020-07-18 00:14:43 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2020-07-18 00:14:43 +0000 |
commit | 7cd4443fb1c7396367c74421289fec7cd60ddfbd (patch) | |
tree | 7e2e509232ed44b35415685e630d8c29301cdae2 /sys/kern | |
parent | 1bd12a3bb2be72a7d360402f489000dd337f6f3b (diff) | |
download | src-7cd4443fb1c7396367c74421289fec7cd60ddfbd.tar.gz src-7cd4443fb1c7396367c74421289fec7cd60ddfbd.zip |
Short-circuit tdfind when looking for the calling thread.
Common occurence with cpuset and other places.
Notes
Notes:
svn path=/head/; revision=363297
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_thread.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 46b410a85362..8216c31ef0c0 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1299,6 +1299,14 @@ tdfind(lwpid_t tid, pid_t pid) struct thread *td; int run = 0; + td = curthread; + if (td->td_tid == tid) { + if (pid != -1 && td->td_proc->p_pid != pid) + return (NULL); + PROC_LOCK(td->td_proc); + return (td); + } + rw_rlock(&tidhash_lock); LIST_FOREACH(td, TIDHASH(tid), td_hash) { if (td->td_tid == tid) { |