Date: Thu, 2 Jul 2020 10:40:48 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362885 - head/sys/kern Message-ID: <202007021040.062AemlD002519@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Thu Jul 2 10:40:47 2020 New Revision: 362885 URL: https://svnweb.freebsd.org/changeset/base/362885 Log: Use tdfind() in pget(). Reviewed by: jhb, hselasky Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D25532 Modified: head/sys/kern/kern_proc.c Modified: head/sys/kern/kern_proc.c ============================================================================== --- head/sys/kern/kern_proc.c Thu Jul 2 07:15:48 2020 (r362884) +++ head/sys/kern/kern_proc.c Thu Jul 2 10:40:47 2020 (r362885) @@ -455,30 +455,6 @@ pfind_any(pid_t pid) return (_pfind(pid, true)); } -static struct proc * -pfind_tid(pid_t tid) -{ - struct proc *p; - struct thread *td; - - sx_slock(&allproc_lock); - FOREACH_PROC_IN_SYSTEM(p) { - PROC_LOCK(p); - if (p->p_state == PRS_NEW) { - PROC_UNLOCK(p); - continue; - } - FOREACH_THREAD_IN_PROC(p, td) { - if (td->td_tid == tid) - goto found; - } - PROC_UNLOCK(p); - } -found: - sx_sunlock(&allproc_lock); - return (p); -} - /* * Locate a process group by number. * The caller must hold proctree_lock. @@ -506,6 +482,7 @@ int pget(pid_t pid, int flags, struct proc **pp) { struct proc *p; + struct thread *td1; int error; p = curproc; @@ -519,7 +496,9 @@ pget(pid_t pid, int flags, struct proc **pp) else p = pfind(pid); } else if ((flags & PGET_NOTID) == 0) { - p = pfind_tid(pid); + td1 = tdfind(pid, -1); + if (td1 != NULL) + p = td1->td_proc; } if (p == NULL) return (ESRCH);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007021040.062AemlD002519>