From owner-p4-projects@FreeBSD.ORG Fri Oct 12 11:55:35 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DE25B16A46E; Fri, 12 Oct 2007 11:55:34 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8BDD716A46C for ; Fri, 12 Oct 2007 11:55:34 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 6D1B813C447 for ; Fri, 12 Oct 2007 11:55:34 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l9CBtYwh023692 for ; Fri, 12 Oct 2007 11:55:34 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l9CBtY79023689 for perforce@freebsd.org; Fri, 12 Oct 2007 11:55:34 GMT (envelope-from zec@FreeBSD.org) Date: Fri, 12 Oct 2007 11:55:34 GMT Message-Id: <200710121155.l9CBtY79023689@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 127424 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: Fri, 12 Oct 2007 11:55:35 -0000 http://perforce.freebsd.org/chv.cgi?CH=127424 Change 127424 by zec@zec_tpx32 on 2007/10/12 11:55:17 Allow for a process in parent vprocg waiting for a child proc executing in a child vprocg context to be woken up when the child proc exits. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_exit.c#8 edit .. //depot/projects/vimage/src/sys/kern/kern_prot.c#5 edit .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#40 edit .. //depot/projects/vimage/src/sys/kern/sched_4bsd.c#13 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#41 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_exit.c#8 (text+ko) ==== @@ -176,13 +176,8 @@ ("exit1: proc %p exiting with %d threads", p, p->p_numthreads)); #ifdef VIMAGE - /* - * Switch back to vprocg of our parent so we can deliver - * signals, otherwise we won't die - why?!? XXX - * - * XXX is PROC_UNLOCK()/PROC_LOCK() sequence safe here? - */ - if (p->p_pptr && p->p_ucred->cr_vimage->v_procg != + /* XXX is PROC_UNLOCK()/PROC_LOCK() sequence safe here? */ + if (p->p_ucred->cr_vimage->v_procg != p->p_pptr->p_ucred->cr_vimage->v_procg) { struct ucred *oldcred; @@ -190,12 +185,12 @@ crhold(p->p_pptr->p_ucred); oldcred = p->p_ucred; p->p_ucred = p->p_pptr->p_ucred; + PROC_UNLOCK(p); + sx_xlock(&allproc_lock); #ifdef SCHED_4BSD sched_load_reassign(oldcred->cr_vimage->v_procg, p->p_ucred->cr_vimage->v_procg); #endif - PROC_UNLOCK(p); - sx_xlock(&allproc_lock); oldcred->cr_vimage->v_procg->nprocs--; p->p_ucred->cr_vimage->v_procg->nprocs++; sx_xunlock(&allproc_lock); ==== //depot/projects/vimage/src/sys/kern/kern_prot.c#5 (text+ko) ==== @@ -46,6 +46,7 @@ #include "opt_compat.h" #include "opt_mac.h" +#include "opt_vimage.h" #include #include @@ -67,6 +68,7 @@ #include #include #include +#include #include #include @@ -1720,6 +1722,9 @@ KASSERT(td == curthread, ("%s: td not curthread", __func__)); PROC_LOCK_ASSERT(p, MA_OWNED); +#ifdef VIMAGE + if (!vi_child_of(td->td_ucred->cr_vimage, p->p_ucred->cr_vimage)) +#endif if ((error = prison_check(td->td_ucred, p->p_ucred))) return (error); #ifdef MAC ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#40 (text+ko) ==== @@ -67,7 +67,6 @@ static void vnet_mod_complete_registration(struct vnet_modlink *); static int vnet_mod_constructor(struct vnet_modlink *); static int vnet_mod_destructor(struct vnet_modlink *); -static int vi_child_of(struct vimage *, struct vimage *); #ifdef VI_PREALLOC_SIZE /* @@ -517,7 +516,7 @@ /* * XXX priv_check()? * XXX refcounting ucred -> vimage ? - * XXX change ucred for proc or thread, or both? + * XXX allow only a single td per proc here? */ newcred = crget(); PROC_LOCK(p); ==== //depot/projects/vimage/src/sys/kern/sched_4bsd.c#13 (text+ko) ==== @@ -239,7 +239,7 @@ INIT_VPROCG(td->td_ucred->cr_vimage->v_procg); V_sched_tdcnt++; - CTR1(KTR_SCHED, "global load: %d", sched_tdcnt); + CTR1(KTR_SCHED, "global load: %d", V_sched_tdcnt); } static __inline void @@ -248,7 +248,7 @@ INIT_VPROCG(td->td_ucred->cr_vimage->v_procg); V_sched_tdcnt--; - CTR1(KTR_SCHED, "global load: %d", sched_tdcnt); + CTR1(KTR_SCHED, "global load: %d", V_sched_tdcnt); } #ifdef VIMAGE @@ -1361,19 +1361,15 @@ thread_unlock(td); } +int #ifdef VIMAGE -int sched_load(struct vprocg *vprocg) -{ - return (V_sched_tdcnt); -} #else -int sched_load(void) +#endif { - return (sched_tdcnt); + return (V_sched_tdcnt); } -#endif int sched_sizeof_proc(void) ==== //depot/projects/vimage/src/sys/sys/vimage.h#41 (text+ko) ==== @@ -318,6 +318,7 @@ int vi_symlookup(struct kld_sym_lookup *, char *); struct vimage *vnet2vimage(struct vnet *); char *vnet_name(struct vnet *); +int vi_child_of(struct vimage *, struct vimage *); LIST_HEAD(vimage_list_head, vimage); extern struct vimage_list_head vimage_head;