Short-circuit tdfind when looking for the calling thread.

Common occurence with cpuset and other places.
This commit is contained in:
Mateusz Guzik 2020-07-18 00:14:43 +00:00
parent 1bd12a3bb2
commit 7cd4443fb1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363297

View File

@ -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) {