From owner-svn-src-all@freebsd.org Sat Jan 9 14:53:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 59338A6987F; Sat, 9 Jan 2016 14:53:11 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 301A7186F; Sat, 9 Jan 2016 14:53:11 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u09ErATa008635; Sat, 9 Jan 2016 14:53:10 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u09Er8S5008620; Sat, 9 Jan 2016 14:53:08 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201601091453.u09Er8S5008620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 9 Jan 2016 14:53:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r293490 - in stable/10/sys: amd64/amd64 arm/arm compat/ia32 compat/svr4 i386/i386 i386/ibcs2 kern mips/mips powerpc/powerpc sparc64/sparc64 sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2016 14:53:11 -0000 Author: dchagin Date: Sat Jan 9 14:53:08 2016 New Revision: 293490 URL: https://svnweb.freebsd.org/changeset/base/293490 Log: MFC r283382: In preparation for switching linuxulator to the use the native 1:1 threads add a hook for cleaning thread resources before the thread die. Modified: stable/10/sys/amd64/amd64/elf_machdep.c stable/10/sys/arm/arm/elf_machdep.c stable/10/sys/compat/ia32/ia32_sysvec.c stable/10/sys/compat/svr4/svr4_sysvec.c stable/10/sys/i386/i386/elf_machdep.c stable/10/sys/i386/ibcs2/ibcs2_sysvec.c stable/10/sys/kern/imgact_aout.c stable/10/sys/kern/init_main.c stable/10/sys/kern/kern_thread.c stable/10/sys/mips/mips/elf_machdep.c stable/10/sys/mips/mips/freebsd32_machdep.c stable/10/sys/powerpc/powerpc/elf32_machdep.c stable/10/sys/powerpc/powerpc/elf64_machdep.c stable/10/sys/sparc64/sparc64/elf_machdep.c stable/10/sys/sys/sysent.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/10/sys/amd64/amd64/elf_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/amd64/amd64/elf_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/arm/arm/elf_machdep.c ============================================================================== --- stable/10/sys/arm/arm/elf_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/arm/arm/elf_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -79,6 +79,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: stable/10/sys/compat/ia32/ia32_sysvec.c ============================================================================== --- stable/10/sys/compat/ia32/ia32_sysvec.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/compat/ia32/ia32_sysvec.c Sat Jan 9 14:53:08 2016 (r293490) @@ -139,6 +139,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: stable/10/sys/compat/svr4/svr4_sysvec.c ============================================================================== --- stable/10/sys/compat/svr4/svr4_sysvec.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/compat/svr4/svr4_sysvec.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/i386/i386/elf_machdep.c ============================================================================== --- stable/10/sys/i386/i386/elf_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/i386/i386/elf_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/i386/ibcs2/ibcs2_sysvec.c ============================================================================== --- stable/10/sys/i386/ibcs2/ibcs2_sysvec.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/i386/ibcs2/ibcs2_sysvec.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/kern/imgact_aout.c ============================================================================== --- stable/10/sys/kern/imgact_aout.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/kern/imgact_aout.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/kern/init_main.c ============================================================================== --- stable/10/sys/kern/init_main.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/kern/init_main.c Sat Jan 9 14:53:08 2016 (r293490) @@ -414,6 +414,7 @@ struct sysentvec null_sysvec = { .sv_fetch_syscall_args = null_fetch_syscall_args, .sv_syscallnames = NULL, .sv_schedtail = NULL, + .sv_thread_detach = NULL, }; /* Modified: stable/10/sys/kern/kern_thread.c ============================================================================== --- stable/10/sys/kern/kern_thread.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/kern/kern_thread.c Sat Jan 9 14:53:08 2016 (r293490) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -885,6 +886,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: stable/10/sys/mips/mips/elf_machdep.c ============================================================================== --- stable/10/sys/mips/mips/elf_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/mips/mips/elf_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/mips/mips/freebsd32_machdep.c ============================================================================== --- stable/10/sys/mips/mips/freebsd32_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/mips/mips/freebsd32_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/powerpc/powerpc/elf32_machdep.c ============================================================================== --- stable/10/sys/powerpc/powerpc/elf32_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/powerpc/powerpc/elf32_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -107,6 +107,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: stable/10/sys/powerpc/powerpc/elf64_machdep.c ============================================================================== --- stable/10/sys/powerpc/powerpc/elf64_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/powerpc/powerpc/elf64_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -83,6 +83,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: stable/10/sys/sparc64/sparc64/elf_machdep.c ============================================================================== --- stable/10/sys/sparc64/sparc64/elf_machdep.c Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/sparc64/sparc64/elf_machdep.c Sat Jan 9 14:53:08 2016 (r293490) @@ -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: stable/10/sys/sys/sysent.h ============================================================================== --- stable/10/sys/sys/sysent.h Sat Jan 9 14:51:50 2016 (r293489) +++ stable/10/sys/sys/sysent.h Sat Jan 9 14:53:08 2016 (r293490) @@ -130,6 +130,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