aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-07-18 00:14:43 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-07-18 00:14:43 +0000
commit7cd4443fb1c7396367c74421289fec7cd60ddfbd (patch)
tree7e2e509232ed44b35415685e630d8c29301cdae2 /sys/kern
parent1bd12a3bb2be72a7d360402f489000dd337f6f3b (diff)
downloadsrc-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.c8
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) {