Use tdfind() in pget().

Reviewed by:	jhb, hselasky
Sponsored by:	Mellanox Technologies
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25532
This commit is contained in:
Konstantin Belousov 2020-07-02 10:40:47 +00:00
parent 771f100ceb
commit 4bc5ce2c74
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362885

View File

@ -455,30 +455,6 @@ pfind_any(pid_t pid)
return (_pfind(pid, true)); 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. * Locate a process group by number.
* The caller must hold proctree_lock. * The caller must hold proctree_lock.
@ -506,6 +482,7 @@ int
pget(pid_t pid, int flags, struct proc **pp) pget(pid_t pid, int flags, struct proc **pp)
{ {
struct proc *p; struct proc *p;
struct thread *td1;
int error; int error;
p = curproc; p = curproc;
@ -519,7 +496,9 @@ pget(pid_t pid, int flags, struct proc **pp)
else else
p = pfind(pid); p = pfind(pid);
} else if ((flags & PGET_NOTID) == 0) { } else if ((flags & PGET_NOTID) == 0) {
p = pfind_tid(pid); td1 = tdfind(pid, -1);
if (td1 != NULL)
p = td1->td_proc;
} }
if (p == NULL) if (p == NULL)
return (ESRCH); return (ESRCH);