Extend struct sysvec with new method sv_schedtail, which is used for an

explicit process at fork trampoline path instead of eventhadler(schedtail)
invocation for each child process.

Remove eventhandler(schedtail) code and change linux ABI to use newly added
sysvec method.

While here replace explicit comparing of module sysentvec structure with the
newly created process sysentvec to detect the linux ABI.

Discussed with:	kib

MFC after:	2 Week
This commit is contained in:
Dmitry Chagin 2011-03-08 19:01:45 +00:00
parent cae905e5d0
commit e5d81ef1b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219405
21 changed files with 28 additions and 14 deletions

View File

@ -81,6 +81,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_syscallnames = syscallnames,
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);

View File

@ -128,7 +128,6 @@ static void linux32_fixlimit(struct rlimit *rl, int which);
static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
static eventhandler_tag linux_exit_tag;
static eventhandler_tag linux_schedtail_tag;
static eventhandler_tag linux_exec_tag;
/*
@ -1063,6 +1062,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = linux32_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = linux_schedtail,
};
static char GNU_ABI_VENDOR[] = "GNU";
@ -1156,8 +1156,6 @@ linux_elf_modevent(module_t mod, int type, void *data)
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
linux_proc_exit, NULL, 1000);
linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail,
linux_schedtail, NULL, 1000);
linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
linux_proc_exec, NULL, 1000);
linux_szplatform = roundup(strlen(linux_platform) + 1,
@ -1189,7 +1187,6 @@ linux_elf_modevent(module_t mod, int type, void *data)
sx_destroy(&emul_shared_lock);
mtx_destroy(&futex_mtx);
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
linux_osd_jail_deregister();
if (bootverbose)

View File

@ -78,6 +78,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = NULL, /* XXXKIB */
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -149,6 +149,7 @@ struct sysentvec ia32_freebsd_sysvec = {
.sv_syscallnames = freebsd32_syscallnames,
.sv_shared_page_base = FREEBSD32_SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
};
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);

View File

@ -300,13 +300,16 @@ linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
}
void
linux_schedtail(void *arg __unused, struct proc *p)
linux_schedtail(struct thread *td)
{
struct linux_emuldata *em;
struct proc *p;
int error = 0;
int *child_set_tid;
if (__predict_true(p->p_sysent != &elf_linux_sysvec))
p = td->td_proc;
if (SV_PROC_ABI(p) != SV_ABI_LINUX)
return;
/* find the emuldata */

View File

@ -82,7 +82,7 @@ struct linux_emuldata *em_find(struct proc *, int locked);
int linux_proc_init(struct thread *, pid_t, int);
void linux_proc_exit(void *, struct proc *);
void linux_schedtail(void *, struct proc *);
void linux_schedtail(struct thread *);
void linux_proc_exec(void *, struct proc *, struct image_params *);
void linux_kill_threads(struct thread *, int);

View File

@ -195,6 +195,7 @@ struct sysentvec svr4_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
};
const char svr4_emul_path[] = "/compat/svr4";

View File

@ -78,6 +78,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -90,6 +90,7 @@ struct sysentvec ibcs2_svr3_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
};
static int

View File

@ -112,7 +112,6 @@ static int linux_szplatform;
const char *linux_platform;
static eventhandler_tag linux_exit_tag;
static eventhandler_tag linux_schedtail_tag;
static eventhandler_tag linux_exec_tag;
/*
@ -998,6 +997,7 @@ struct sysentvec linux_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = linux_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = linux_schedtail,
};
struct sysentvec elf_linux_sysvec = {
@ -1032,6 +1032,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = linux_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = linux_schedtail,
};
static char GNU_ABI_VENDOR[] = "GNU";
@ -1125,8 +1126,6 @@ linux_elf_modevent(module_t mod, int type, void *data)
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit,
NULL, 1000);
linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail,
NULL, 1000);
linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
NULL, 1000);
linux_get_machine(&linux_platform);
@ -1159,7 +1158,6 @@ linux_elf_modevent(module_t mod, int type, void *data)
sx_destroy(&emul_shared_lock);
mtx_destroy(&futex_mtx);
EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag);
EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
linux_osd_jail_deregister();
if (bootverbose)

View File

@ -85,6 +85,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf64_Brandinfo freebsd_brand_info = {

View File

@ -93,6 +93,7 @@ struct sysentvec aout_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static int

View File

@ -378,6 +378,7 @@ struct sysentvec null_sysvec = {
.sv_set_syscall_retval = null_set_syscall_retval,
.sv_fetch_syscall_args = null_fetch_syscall_args,
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
};
/*

View File

@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <sys/unistd.h>
#include <sys/sdt.h>
#include <sys/sx.h>
#include <sys/sysent.h>
#include <sys/signalvar.h>
#include <security/audit/audit.h>
@ -895,7 +896,8 @@ fork_exit(void (*callout)(void *, struct trapframe *), void *arg,
}
mtx_assert(&Giant, MA_NOTOWNED);
EVENTHANDLER_INVOKE(schedtail, p);
if (p->p_sysent->sv_schedtail != NULL)
(p->p_sysent->sv_schedtail)(td);
}
/*

View File

@ -82,6 +82,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = NULL, /* XXXKIB */
.sv_syscallnames = NULL,
.sv_schedtail = NULL,
};
static Elf64_Brandinfo freebsd_brand_gnutools_info64 = {

View File

@ -82,6 +82,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = NULL, /* XXXKIB */
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf64_Brandinfo freebsd_brand_info = {
@ -137,6 +138,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = NULL, /* XXXKIB */
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf32_Brandinfo freebsd_brand_info = {

View File

@ -106,6 +106,7 @@ struct sysentvec elf32_freebsd_sysvec = {
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_shared_page_base = FREEBSD32_SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);

View File

@ -82,6 +82,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_syscallnames = syscallnames,
.sv_shared_page_base = SHAREDPAGE,
.sv_shared_page_len = PAGE_SIZE,
.sv_schedtail = NULL,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);

View File

@ -93,6 +93,7 @@ static struct sysentvec elf64_freebsd_sysvec = {
.sv_set_syscall_retval = cpu_set_syscall_retval,
.sv_fetch_syscall_args = cpu_fetch_syscall_args,
.sv_syscallnames = syscallnames,
.sv_schedtail = NULL,
};
static Elf64_Brandinfo freebsd_brand_info = {

View File

@ -250,6 +250,4 @@ typedef void (*uma_zone_chfn)(void *);
EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn);
EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn);
typedef void(*schedtail_fn)(void *, struct proc *);
EVENTHANDLER_DECLARE(schedtail, schedtail_fn);
#endif /* SYS_EVENTHANDLER_H */

View File

@ -125,6 +125,7 @@ struct sysentvec {
vm_offset_t sv_shared_page_len;
vm_offset_t sv_sigcode_base;
void *sv_shared_page_obj;
void (*sv_schedtail)(struct thread *);
};
#define SV_ILP32 0x000100