summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2015-05-24 14:51:29 +0000
committerdchagin <dchagin@FreeBSD.org>2015-05-24 14:51:29 +0000
commitca0fda407756a0fda8db3d6d464117c2c88b48d0 (patch)
tree29e72220b49ea68b1cf3385e3c206b1a59e70098
parent745df0287fcf54634f0950689d0ffaebcfed8d8c (diff)
downloadFreeBSD-src-ca0fda407756a0fda8db3d6d464117c2c88b48d0.zip
FreeBSD-src-ca0fda407756a0fda8db3d6d464117c2c88b48d0.tar.gz
In preparation for switching linuxulator to the use the native 1:1
threads add a hook for cleaning thread resources before the thread die. Differential Revision: https://reviews.freebsd.org/D1038
-rw-r--r--sys/amd64/amd64/elf_machdep.c1
-rw-r--r--sys/arm/arm/elf_machdep.c1
-rw-r--r--sys/compat/ia32/ia32_sysvec.c1
-rw-r--r--sys/compat/svr4/svr4_sysvec.c1
-rw-r--r--sys/i386/i386/elf_machdep.c1
-rw-r--r--sys/i386/ibcs2/ibcs2_sysvec.c1
-rw-r--r--sys/kern/imgact_aout.c1
-rw-r--r--sys/kern/init_main.c1
-rw-r--r--sys/kern/kern_thread.c9
-rw-r--r--sys/mips/mips/elf_machdep.c2
-rw-r--r--sys/mips/mips/freebsd32_machdep.c1
-rw-r--r--sys/powerpc/powerpc/elf32_machdep.c1
-rw-r--r--sys/powerpc/powerpc/elf64_machdep.c1
-rw-r--r--sys/sparc64/sparc64/elf_machdep.c1
-rw-r--r--sys/sys/sysent.h1
15 files changed, 24 insertions, 0 deletions
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index 23fa39b..d1cffd9 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -82,6 +82,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c
index 598decc..e5cc6a0 100644
--- a/sys/arm/arm/elf_machdep.c
+++ b/sys/arm/arm/elf_machdep.c
@@ -81,6 +81,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
static Elf32_Brandinfo freebsd_brand_info = {
diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c
index 6dd02af..51a9e9f 100644
--- a/sys/compat/ia32/ia32_sysvec.c
+++ b/sys/compat/ia32/ia32_sysvec.c
@@ -136,6 +136,7 @@ struct sysentvec ia32_freebsd_sysvec = {
.sv_shared_page_base = FREEBSD32_SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c
index 561a838..125a7d8 100644
--- a/sys/compat/svr4/svr4_sysvec.c
+++ b/sys/compat/svr4/svr4_sysvec.c
@@ -196,6 +196,7 @@ struct sysentvec svr4_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
const char svr4_emul_path[] = "/compat/svr4";
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
index 8cd4440..03ab10f 100644
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -88,6 +88,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
diff --git a/sys/i386/ibcs2/ibcs2_sysvec.c b/sys/i386/ibcs2/ibcs2_sysvec.c
index 5d007c7..16507ee 100644
--- a/sys/i386/ibcs2/ibcs2_sysvec.c
+++ b/sys/i386/ibcs2/ibcs2_sysvec.c
@@ -89,6 +89,7 @@ struct sysentvec ibcs2_svr3_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
static int
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 3ae78de..edd5f5f 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -99,6 +99,7 @@ struct sysentvec aout_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
#elif defined(__amd64__)
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index c263356..cf4eed1 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -411,6 +411,7 @@ struct sysentvec null_sysvec = {
.sv_fetch_syscall_args = null_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
/*
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 0dd5f46..dce760c 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sched.h>
#include <sys/sleepqueue.h>
#include <sys/selinfo.h>
+#include <sys/sysent.h>
#include <sys/turnstile.h>
#include <sys/ktr.h>
#include <sys/rwlock.h>
@@ -884,6 +885,14 @@ thread_suspend_check(int return_instead)
if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) {
PROC_UNLOCK(p);
tidhash_remove(td);
+
+ /*
+ * Allow Linux emulation layer to do some work
+ * before thread suicide.
+ */
+ if (__predict_false(p->p_sysent->sv_thread_detach != NULL))
+ (p->p_sysent->sv_thread_detach)(td);
+
PROC_LOCK(p);
tdsigcleanup(td);
umtx_thread_exit(td);
diff --git a/sys/mips/mips/elf_machdep.c b/sys/mips/mips/elf_machdep.c
index d374713..8cbe8d3 100644
--- a/sys/mips/mips/elf_machdep.c
+++ b/sys/mips/mips/elf_machdep.c
@@ -83,6 +83,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
static Elf64_Brandinfo freebsd_brand_info = {
@@ -139,6 +140,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
static Elf32_Brandinfo freebsd_brand_info = {
diff --git a/sys/mips/mips/freebsd32_machdep.c b/sys/mips/mips/freebsd32_machdep.c
index 9de4685b..4110e13 100644
--- a/sys/mips/mips/freebsd32_machdep.c
+++ b/sys/mips/mips/freebsd32_machdep.c
@@ -106,6 +106,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = freebsd32_syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
diff --git a/sys/powerpc/powerpc/elf32_machdep.c b/sys/powerpc/powerpc/elf32_machdep.c
index ea00306..bdcd9ba 100644
--- a/sys/powerpc/powerpc/elf32_machdep.c
+++ b/sys/powerpc/powerpc/elf32_machdep.c
@@ -108,6 +108,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_shared_page_base = FREEBSD32_SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
diff --git a/sys/powerpc/powerpc/elf64_machdep.c b/sys/powerpc/powerpc/elf64_machdep.c
index 0b15ca3..47fbbff 100644
--- a/sys/powerpc/powerpc/elf64_machdep.c
+++ b/sys/powerpc/powerpc/elf64_machdep.c
@@ -84,6 +84,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
diff --git a/sys/sparc64/sparc64/elf_machdep.c b/sys/sparc64/sparc64/elf_machdep.c
index 4d55717..9304575 100644
--- a/sys/sparc64/sparc64/elf_machdep.c
+++ b/sys/sparc64/sparc64/elf_machdep.c
@@ -87,6 +87,7 @@ static struct sysentvec elf64_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
+ .sv_thread_detach = NULL,
};
static Elf64_Brandinfo freebsd_brand_info = {
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index bef27ce..b1f61a9 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -136,6 +136,7 @@ struct sysentvec {
uint32_t sv_timekeep_gen;
void *sv_shared_page_obj;
void (*sv_schedtail)(struct thread *);
+ void (*sv_thread_detach)(struct thread *);
};
#define SV_ILP32 0x000100
OpenPOWER on IntegriCloud