From owner-svn-src-head@freebsd.org Thu Jul 2 10:40:48 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 953413514EE; Thu, 2 Jul 2020 10:40:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49yF4J3TKCz4f0c; Thu, 2 Jul 2020 10:40:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5A9C5195ED; Thu, 2 Jul 2020 10:40:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 062AemSi002537; Thu, 2 Jul 2020 10:40:48 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 062AemlD002519; Thu, 2 Jul 2020 10:40:48 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202007021040.062AemlD002519@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 2 Jul 2020 10:40:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362885 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 362885 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 10:40:48 -0000 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);