From eadb1dcb71bf317c19abe4d4a427fbfbf24f116a Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 8 Dec 2018 06:31:43 +0000 Subject: [PATCH] proc: handle sdt exit probe before taking the proc lock Sponsored by: The FreeBSD Foundation --- sys/kern/kern_exit.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 461ecc2270c..29016ca380a 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -556,6 +556,17 @@ exit1(struct thread *td, int rval, int signo) PROC_UNLOCK(q); } +#ifdef KDTRACE_HOOKS + if (SDT_PROBES_ENABLED()) { + int reason = CLD_EXITED; + if (WCOREDUMP(signo)) + reason = CLD_DUMPED; + else if (WIFSIGNALED(signo)) + reason = CLD_KILLED; + SDT_PROBE1(proc, , , exit, reason); + } +#endif + /* Save exit status. */ PROC_LOCK(p); p->p_xthread = td; @@ -574,15 +585,6 @@ exit1(struct thread *td, int rval, int signo) */ KNOTE_LOCKED(p->p_klist, NOTE_EXIT); -#ifdef KDTRACE_HOOKS - int reason = CLD_EXITED; - if (WCOREDUMP(signo)) - reason = CLD_DUMPED; - else if (WIFSIGNALED(signo)) - reason = CLD_KILLED; - SDT_PROBE1(proc, , , exit, reason); -#endif - /* * If this is a process with a descriptor, we may not need to deliver * a signal to the parent. proctree_lock is held over