Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 14:51:30 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283382 - in head/sys: amd64/amd64 arm/arm compat/ia32 compat/svr4 i386/i386 i386/ibcs2 kern mips/mips powerpc/powerpc sparc64/sparc64 sys
Message-ID:  <201505241451.t4OEpUad033423@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 24 14:51:29 2015
New Revision: 283382
URL: https://svnweb.freebsd.org/changeset/base/283382

Log:
  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

Modified:
  head/sys/amd64/amd64/elf_machdep.c
  head/sys/arm/arm/elf_machdep.c
  head/sys/compat/ia32/ia32_sysvec.c
  head/sys/compat/svr4/svr4_sysvec.c
  head/sys/i386/i386/elf_machdep.c
  head/sys/i386/ibcs2/ibcs2_sysvec.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/init_main.c
  head/sys/kern/kern_thread.c
  head/sys/mips/mips/elf_machdep.c
  head/sys/mips/mips/freebsd32_machdep.c
  head/sys/powerpc/powerpc/elf32_machdep.c
  head/sys/powerpc/powerpc/elf64_machdep.c
  head/sys/sparc64/sparc64/elf_machdep.c
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- head/sys/amd64/amd64/elf_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/amd64/amd64/elf_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/arm/arm/elf_machdep.c
==============================================================================
--- head/sys/arm/arm/elf_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/arm/arm/elf_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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 = {

Modified: head/sys/compat/ia32/ia32_sysvec.c
==============================================================================
--- head/sys/compat/ia32/ia32_sysvec.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/compat/ia32/ia32_sysvec.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/compat/svr4/svr4_sysvec.c
==============================================================================
--- head/sys/compat/svr4/svr4_sysvec.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/compat/svr4/svr4_sysvec.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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";

Modified: head/sys/i386/i386/elf_machdep.c
==============================================================================
--- head/sys/i386/i386/elf_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/i386/i386/elf_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/i386/ibcs2/ibcs2_sysvec.c
==============================================================================
--- head/sys/i386/ibcs2/ibcs2_sysvec.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/i386/ibcs2/ibcs2_sysvec.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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

Modified: head/sys/kern/imgact_aout.c
==============================================================================
--- head/sys/kern/imgact_aout.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/kern/imgact_aout.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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__)

Modified: head/sys/kern/init_main.c
==============================================================================
--- head/sys/kern/init_main.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/kern/init_main.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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,
 };
 
 /*

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/kern/kern_thread.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);

Modified: head/sys/mips/mips/elf_machdep.c
==============================================================================
--- head/sys/mips/mips/elf_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/mips/mips/elf_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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 = {

Modified: head/sys/mips/mips/freebsd32_machdep.c
==============================================================================
--- head/sys/mips/mips/freebsd32_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/mips/mips/freebsd32_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/powerpc/powerpc/elf32_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/elf32_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/powerpc/powerpc/elf32_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/powerpc/powerpc/elf64_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/elf64_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/powerpc/powerpc/elf64_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -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);
 

Modified: head/sys/sparc64/sparc64/elf_machdep.c
==============================================================================
--- head/sys/sparc64/sparc64/elf_machdep.c	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/sparc64/sparc64/elf_machdep.c	Sun May 24 14:51:29 2015	(r283382)
@@ -87,6 +87,7 @@ static struct sysentvec elf64_freebsd_sy
 	.sv_fetch_syscall_args = cpu_fetch_syscall_args,
 	.sv_syscallnames = syscallnames,
 	.sv_schedtail	= NULL,
+	.sv_thread_detach = NULL,
 };
 
 static Elf64_Brandinfo freebsd_brand_info = {

Modified: head/sys/sys/sysent.h
==============================================================================
--- head/sys/sys/sysent.h	Sun May 24 14:49:21 2015	(r283381)
+++ head/sys/sys/sysent.h	Sun May 24 14:51:29 2015	(r283382)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241451.t4OEpUad033423>