aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2017-03-14 15:53:24 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2017-03-14 15:53:24 +0000
commitd19861402fcb7a0bb964883da7032df94fe09cef (patch)
tree285555947f523decb248e9d639d2e6aed56f1783
parent2f9eb63eee053d46294fa4a5f2f1d63480476bc8 (diff)
downloadsrc-d19861402fcb7a0bb964883da7032df94fe09cef.tar.gz
src-d19861402fcb7a0bb964883da7032df94fe09cef.zip
MFC r313941:
Make sure the thread constructor and destructor eventhandlers are called for all threads belonging to a procedure. Currently the first thread in a procedure is kept around as an optimisation step and is never freed. Because the first thread in a procedure is never freed nor allocated, its destructor and constructor callbacks are never called which means per thread structures allocated by dtrace and the Linux emulation layers for example, might be present for threads which don't need these structures. This patch adds a thread construction and destruction call for the first thread in a procedure. Tested: dtrace, linux emulation Reviewed by: kib @ Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/stable/8/; revision=315262
-rw-r--r--sys/kern/kern_proc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 864afedea94e..58bae5241b06 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -181,11 +181,17 @@ static int
proc_ctor(void *mem, int size, void *arg, int flags)
{
struct proc *p;
+ struct thread *td;
p = (struct proc *)mem;
SDT_PROBE(proc, kernel, ctor , entry, p, size, arg, flags, 0);
EVENTHANDLER_INVOKE(process_ctor, p);
SDT_PROBE(proc, kernel, ctor , return, p, size, arg, flags, 0);
+ td = FIRST_THREAD_IN_PROC(p);
+ if (td != NULL) {
+ /* Make sure all thread constructors are executed */
+ EVENTHANDLER_INVOKE(thread_ctor, td);
+ }
return (0);
}
@@ -210,6 +216,9 @@ proc_dtor(void *mem, int size, void *arg)
#endif
/* Free all OSD associated to this thread. */
osd_thread_exit(td);
+
+ /* Make sure all thread destructors are executed */
+ EVENTHANDLER_INVOKE(thread_dtor, td);
}
EVENTHANDLER_INVOKE(process_dtor, p);
if (p->p_ksi != NULL)