Date: Sat, 18 Jul 2020 00:14:43 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363297 - head/sys/kern Message-ID: <202007180014.06I0EhrL005895@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Sat Jul 18 00:14:43 2020 New Revision: 363297 URL: https://svnweb.freebsd.org/changeset/base/363297 Log: Short-circuit tdfind when looking for the calling thread. Common occurence with cpuset and other places. Modified: head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_thread.c ============================================================================== --- head/sys/kern/kern_thread.c Fri Jul 17 23:10:35 2020 (r363296) +++ head/sys/kern/kern_thread.c Sat Jul 18 00:14:43 2020 (r363297) @@ -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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007180014.06I0EhrL005895>