From 80cf427b8dc18bc5c26fed6d07bc5c5eda4545b0 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 29 Mar 2023 08:45:46 +0000 Subject: [PATCH] proc: shave a lock trip on exit if possible ... which happens to be vast majority of the time --- sys/kern/kern_exit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 3f64343aea0e..a92d5cc0f642 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -477,9 +477,11 @@ exit1(struct thread *td, int rval, int signo) sx_xunlock(&allproc_lock); sx_xlock(&proctree_lock); - PROC_LOCK(p); - p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); - PROC_UNLOCK(p); + if ((p->p_flag & (P_TRACED | P_PPWAIT | P_PPTRACE)) != 0) { + PROC_LOCK(p); + p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE); + PROC_UNLOCK(p); + } /* * killjobc() might drop and re-acquire proctree_lock to