git: 9a7bd3309bec - main - procdesc: Remove dead code
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 Jul 2026 21:07:25 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=9a7bd3309bec08802e8c18c03669812ec3352534
commit 9a7bd3309bec08802e8c18c03669812ec3352534
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-24 20:06:16 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-07-24 20:06:16 +0000
procdesc: Remove dead code
As far as I can see, it is impossible for procdesc_exit() to observe
pd->pd_fpcount == 0: if procdesc_close() decrements that counter to
zero, then it will clean up the procdesc structure too, and this is
atomic with respect to the proctree lock.
No functional change intended.
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58396
---
sys/kern/kern_exit.c | 3 ++-
sys/kern/sys_procdesc.c | 22 ++++------------------
sys/sys/procdesc.h | 2 +-
3 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index b989cbff7720..43d0c2da38c1 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -680,7 +680,8 @@ exit1(struct thread *td, int rval, int signo)
* exit().
*/
signal_parent = 0;
- if (p->p_procdesc == NULL || procdesc_exit(p)) {
+ procdesc_exit(p);
+ if (p->p_procdesc == NULL) {
/*
* Notify parent that we're gone. If parent has the
* PS_NOCLDWAIT flag set, or if the handler is set to SIG_IGN,
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index b913c9109f18..862b59262d0c 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -278,45 +278,31 @@ procdesc_free(struct procdesc *pd)
* We use the proctree_lock to ensure that process exit either happens
* strictly before or strictly after a concurrent call to procdesc_close().
*/
-bool
+void
procdesc_exit(struct proc *p)
{
struct procdesc *pd;
sx_assert(&proctree_lock, SA_XLOCKED);
PROC_LOCK_ASSERT(p, MA_OWNED);
- KASSERT(p->p_procdesc != NULL, ("procdesc_exit: p_procdesc NULL"));
MPASS((p->p_flag & P_WEXIT) != 0);
pd = p->p_procdesc;
+ if (pd == NULL)
+ return;
PROCDESC_LOCK(pd);
- KASSERT(pd->pd_fpcount > 0 || p->p_pptr == p->p_reaper,
- ("procdesc_exit: closed && parent not reaper"));
+ KASSERT(pd->pd_fpcount > 0, ("%s: closed procdesc %p", __func__, pd));
pd->pd_flags |= PDF_EXITED;
pd->pd_xstat = KW_EXITCODE(p->p_xexit, p->p_xsig);
- /*
- * If the process descriptor has been closed, then we have nothing
- * to do; return 1 so that init will get SIGCHLD and do the reaping.
- * Clean up the procdesc now rather than letting it happen during
- * that reap.
- */
- if (pd->pd_fpcount == 0) {
- PROCDESC_UNLOCK(pd);
- pd->pd_proc = NULL;
- p->p_procdesc = NULL;
- procdesc_free(pd);
- return (true);
- }
selwakeup(&pd->pd_selinfo);
KNOTE_LOCKED(&pd->pd_selinfo.si_note, NOTE_EXIT | NOTE_PDSIGCHLD);
PROCDESC_UNLOCK(pd);
/* Wakeup all waiters for this procdesc' process exit. */
wakeup(&p->p_procdesc);
- return (false);
}
void
diff --git a/sys/sys/procdesc.h b/sys/sys/procdesc.h
index ac23dbdcb53b..bb486d9026ba 100644
--- a/sys/sys/procdesc.h
+++ b/sys/sys/procdesc.h
@@ -102,7 +102,7 @@ struct procdesc {
/*
* In-kernel interfaces to process descriptors.
*/
-bool procdesc_exit(struct proc *);
+void procdesc_exit(struct proc *);
void procdesc_fork(struct proc *p, pid_t child_pid);
void procdesc_jobstate(struct proc *p);
int kern_pdgetpid(struct thread *, int fd, const cap_rights_t *,