From owner-p4-projects@FreeBSD.ORG Sat Jul 22 11:00:45 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4133016A4E2; Sat, 22 Jul 2006 11:00:45 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EF26116A4DD for ; Sat, 22 Jul 2006 11:00:44 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EEE0443D46 for ; Sat, 22 Jul 2006 11:00:43 +0000 (GMT) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6MB0haA026286 for ; Sat, 22 Jul 2006 11:00:43 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6MB0hbJ026281 for perforce@freebsd.org; Sat, 22 Jul 2006 11:00:43 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sat, 22 Jul 2006 11:00:43 GMT Message-Id: <200607221100.k6MB0hbJ026281@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 102131 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Jul 2006 11:00:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=102131 Change 102131 by rdivacky@rdivacky_witten on 2006/07/22 11:00:20 Change TID handling to be more like linux and less like NetBSD. Affected files ... .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#5 edit .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#10 edit .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#21 edit .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#10 edit .. //depot/projects/soc2006/rdivacky_linuxolator/kern/kern_fork.c#3 edit .. //depot/projects/soc2006/rdivacky_linuxolator/kern/subr_trap.c#4 edit .. //depot/projects/soc2006/rdivacky_linuxolator/sys/eventhandler.h#4 edit Differences ... ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#5 (text+ko) ==== @@ -92,8 +92,8 @@ #ifdef DEBUG if (ldebug(sys_futex)) + printf("FUTEX: %x: %i, %i\n", (unsigned int)args->uaddr, args->op, args->val); #endif - printf("FUTEX: %x: %i, %i\n", (unsigned int)args->uaddr, args->op, args->val); switch (args->op) { case LINUX_FUTEX_WAIT: ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#10 (text+ko) ==== @@ -788,8 +788,6 @@ int *child_set_tid; /* in clone(): Child's TID to set on clone */ int *child_clear_tid; /* in clone(): Child's TID to clear on exit */ - int *set_tid; /* in clone(): Own TID to set on clone */ - int *clear_tid; /* Own TID to clear on exit */ SLIST_ENTRY(linux_emuldata) emuldatas; }; ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#21 (text+ko) ==== @@ -70,7 +70,7 @@ static int linux_proc_init(struct thread *, pid_t); void linux_proc_exit(void *, struct proc *); -void linux_userret(void *, struct proc *); +void linux_schedtail(void *, struct proc *); void linux_proc_exec(void *, struct proc *, struct image_params *); static struct linux_emuldata *em_find(pid_t pid, int locked); @@ -312,9 +312,6 @@ linux_fork(struct thread *td, struct linux_fork_args *args) { int error; -#if 0 - struct linux_emuldata *em; -#endif #ifdef DEBUG if (ldebug(fork)) @@ -330,14 +327,6 @@ if (error) return (error); -#if 0 - EMUL_RLOCK(&emul_data); - /* impossible to not find it */ - SLIST_FOREACH(em, &emuldata_head, emuldatas) - if (em->pid == td->td_retval[0]) - break; - EMUL_RUNLOCK(&emul_data); -#endif return (0); } @@ -1093,7 +1082,7 @@ static int linux_proc_init(struct thread *td, pid_t child) { - struct linux_emuldata *em, *p_em; + struct linux_emuldata *em; /* XXX: locking? */ if (child != 0) { @@ -1118,24 +1107,11 @@ em->child_clear_tid = NULL; em->child_set_tid = NULL; - /* SLIST is inefficient - use hash instead */ - /* I hope I rewrote the semantics right */ - if (child != 0) { - /* find the emuldata for the parent process */ - p_em = em_find(td->td_proc->p_pid, EMUL_LOCKED); - if (p_em == NULL) { - em->clear_tid = NULL; - em->set_tid = NULL; - } else { - em->clear_tid = p_em->child_clear_tid; - em->set_tid = p_em->child_set_tid; - } - EMUL_WUNLOCK(&emul_lock); - } else { - em->clear_tid = NULL; - em->set_tid = NULL; - EMUL_RUNLOCK(&emul_lock); - } + if (child != 0) + EMUL_WUNLOCK(&emul_lock); + else + EMUL_RUNLOCK(&emul_lock); + return (0); } @@ -1159,18 +1135,20 @@ #endif return; } - if (em->clear_tid != NULL) { + if (em->child_clear_tid != NULL) { struct linux_sys_futex_args cup; int null = 0; - error = copyout(&null, em->clear_tid, sizeof(null)); + error = copyout(&null, em->child_clear_tid, sizeof(null)); if (error) { EMUL_RUNLOCK(&emul_lock); return; } + em->child_clear_tid = NULL; + /* futexes stuff */ - cup.uaddr = em->clear_tid; + cup.uaddr = em->child_clear_tid; cup.op = LINUX_FUTEX_WAKE; cup.val = 0x7fffffff; /* Awake everyone */ cup.timeout = NULL; @@ -1207,6 +1185,7 @@ if (__predict_false(imgp->sysent == &elf32_freebsd_sysvec && p->p_sysent == &elf_linux_sysvec)) { struct linux_emuldata *em; + struct thread *td = FIRST_THREAD_IN_PROC(p); em = em_find(p->p_pid, EMUL_UNLOCKED); @@ -1231,16 +1210,14 @@ } void -linux_userret(void *arg __unused, struct proc *p) +linux_schedtail(void *arg __unused, struct proc *p) { struct linux_emuldata *em; int error = 0; - //struct thread *td = FIRST_THREAD_IN_PROC(p); if (p->p_sysent != &elf_linux_sysvec) return; - //printf("XXX: %i\n", p->p_pid); /* find the emuldata */ em = em_find(p->p_pid, EMUL_UNLOCKED); @@ -1251,9 +1228,8 @@ return; } - if (em->set_tid != NULL) { - error = copyout(&p->p_pid, em->set_tid, sizeof(p->p_pid)); - } + if (em->child_set_tid != NULL) + error = copyout(&p->p_pid, em->child_set_tid, sizeof(p->p_pid)); EMUL_RUNLOCK(&emul_lock); return; @@ -1275,7 +1251,7 @@ return (0); } - em->clear_tid = args->tidptr; + em->child_clear_tid = args->tidptr; td->td_retval[0] = td->td_proc->p_pid; EMUL_RUNLOCK(&emul_lock); ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_sysvec.c#10 (text+ko) ==== @@ -109,13 +109,13 @@ extern void linux_proc_exit(void *, struct proc *, struct image_params *); extern void linux_proc_exec(void *, struct proc *, struct image_params *); -extern void linux_userret(void *, struct proc *); +extern void linux_schedtail(void *, struct proc *); extern struct rwlock emul_lock; extern LIST_HEAD(futex_list, futex) futex_list; extern struct mtx futex_mtx; static eventhandler_tag linux_exit_tag; -static eventhandler_tag linux_userret_tag; +static eventhandler_tag linux_schedtail_tag; static eventhandler_tag linux_exec_tag; /* @@ -926,7 +926,7 @@ mtx_init(&futex_mtx, "futex protection lock", NULL, MTX_DEF); linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit, NULL, 1000); - linux_userret_tag = EVENTHANDLER_REGISTER(userret, linux_userret, + linux_schedtail_tag = EVENTHANDLER_REGISTER(schedtail, linux_schedtail, NULL, 1000); linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec, NULL, 1000); @@ -954,7 +954,7 @@ rw_destroy(&emul_lock); mtx_destroy(&futex_mtx); EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag); - EVENTHANDLER_DEREGISTER(userret, linux_userret_tag); + EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag); EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag); break; default: ==== //depot/projects/soc2006/rdivacky_linuxolator/kern/kern_fork.c#3 (text+ko) ==== @@ -831,6 +831,8 @@ kthread_exit(0); } mtx_assert(&Giant, MA_NOTOWNED); + + EVENTHANDLER_INVOKE(schedtail, p); } /* ==== //depot/projects/soc2006/rdivacky_linuxolator/kern/subr_trap.c#4 (text+ko) ==== @@ -59,7 +59,6 @@ #include #include #include -#include #ifdef KTRACE #include #include @@ -129,8 +128,6 @@ addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio); } - EVENTHANDLER_INVOKE(userret, p); - /* * Let the scheduler adjust our priority etc. */ ==== //depot/projects/soc2006/rdivacky_linuxolator/sys/eventhandler.h#4 (text+ko) ==== @@ -176,6 +176,6 @@ EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn); EVENTHANDLER_DECLARE(maxsockets_change, uma_zone_chfn); -typedef void(*userret_fn)(void *, struct proc *); -EVENTHANDLER_DECLARE(userret, userret_fn); +typedef void(*schedtail_fn)(void *, struct proc *); +EVENTHANDLER_DECLARE(schedtail, schedtail_fn); #endif /* SYS_EVENTHANDLER_H */