From owner-p4-projects@FreeBSD.ORG Sat Aug 12 10:47:49 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 59A5F16A4E0; Sat, 12 Aug 2006 10:47:49 +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 2EEA116A4DE for ; Sat, 12 Aug 2006 10:47:49 +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 DA41F43D46 for ; Sat, 12 Aug 2006 10:47:48 +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 k7CAlmKB014367 for ; Sat, 12 Aug 2006 10:47:48 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7CAlmur014364 for perforce@freebsd.org; Sat, 12 Aug 2006 10:47:48 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sat, 12 Aug 2006 10:47:48 GMT Message-Id: <200608121047.k7CAlmur014364@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 103699 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, 12 Aug 2006 10:47:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=103699 Change 103699 by rdivacky@rdivacky_witten on 2006/08/12 10:47:33 Change various if (em == NULL) to KASSERTs. The code is tested enough. Btw: this and last change caused that the code now feels much faster. Affected files ... .. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_misc.c#10 edit .. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#41 edit Differences ... ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_misc.c#10 (text+ko) ==== @@ -1337,12 +1337,7 @@ em = em_find(td->td_proc, EMUL_UNLOCKED); - if (em == NULL) { -#ifdef DEBUG - printf(LMSG("emuldata not found in getpid.\n")); -#endif - return (0); - } + KASSERT(em != NULL, ("getpid: emuldata not found.\n")); td->td_retval[0] = em->shared->group_pid; EMUL_UNLOCK(&emul_lock); @@ -1357,12 +1352,7 @@ em = em_find(td->td_proc, EMUL_UNLOCKED); - if (em == NULL) { -#ifdef DEBUG - printf(LMSG("emuldata for current process not found in getppid.\n")); -#endif - return (0); - } + KASSERT(em != NULL, ("getppid: process emuldata not found.\n")); /* find the group leader */ p = pfind(em->shared->group_pid); @@ -1381,13 +1371,8 @@ /* if its also linux process */ if (pp->p_sysent == &elf_linux_sysvec) { em = em_find(pp, EMUL_LOCKED); - if (em == NULL) { -#ifdef DEBUG - printf(LMSG("emuldata for parent process not found in getppid.\n")); -#endif - PROC_UNLOCK(pp); - return (0); - } + KASSERT(em != NULL, ("getppid: parent emuldata not found.\n")); + td->td_retval[0] = em->shared->group_pid; } else td->td_retval[0] = pp->p_pid; ==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#41 (text+ko) ==== @@ -422,7 +422,7 @@ error = linux_proc_init(td, p2->p_pid, args->flags); /* reference it - no need to check this */ em = em_find(p2, EMUL_UNLOCKED); - KASSERT(em != NULL, ("no emuldata after proc_init()!\n")); + KASSERT(em != NULL, ("clone: emuldata not found.\n")); /* and adjust it */ if (args->flags & CLONE_PARENT_SETTID) { if (args->parent_tidptr == NULL) { @@ -1183,14 +1183,7 @@ } else { /* lookup the old one */ em = em_find(td->td_proc, EMUL_UNLOCKED); - /* XXX: this might be turned into KASSERT once its tested enough */ - if (em == NULL) { - /* this should not happen */ -#ifdef DEBUG - printf(LMSG("emuldata not found in exec case.\n")); -#endif - return (0); - } + KASSERT(em != NULL, ("proc_init: emuldata not found in exec case.\n")); } em->child_clear_tid = NULL; @@ -1204,15 +1197,9 @@ if (flags & CLONE_VM) { /* lookup the parent */ p_em = em_find(td->td_proc, EMUL_LOCKED); - if (p_em == NULL) { -#ifdef DEBUG -#endif - printf(LMSG("parent emuldata not found for CLONE_VM.\n")); - panic("impossible to continue\n"); - } else { - em->shared = p_em->shared; - em->shared->refs++; - } + KASSERT(p_em != NULL, ("proc_init: parent emuldata not found for CLONE_VM\n")); + em->shared = p_em->shared; + em->shared->refs++; } else { /* handled earlier to avoid malloc(M_WAITOK) with rwlock held */ } @@ -1248,12 +1235,7 @@ /* find the emuldata */ em = em_find(p, EMUL_UNLOCKED); - if (em == NULL) { -#ifdef DEBUG - printf(LMSG("we didnt find emuldata for the exiting process.\n")); -#endif - return; - } + KASSERT(em != NULL, ("proc_exit: emuldata not found.\n")); child_clear_tid = em->child_clear_tid; @@ -1311,13 +1293,7 @@ em = em_find(p, EMUL_UNLOCKED); - if (em == NULL) { -#ifdef DEBUG - struct thread *td = FIRST_THREAD_IN_PROC(p); - printf(LMSG("we didnt find emuldata for the execing process.\n")); -#endif - return; - } + KASSERT(em != NULL, ("proc_exec: emuldata not found.\n")); EMUL_UNLOCK(&emul_lock); @@ -1364,10 +1340,7 @@ error = tsleep(&p->p_emuldata, PLOCK, "linux_schedtail", hz); if (error == 0) goto retry; -#ifdef DEBUG - printf(LMSG("we didnt find emuldata for the userreting process.\n")); -#endif - return; + panic("no emuldata found for userreting process.\n"); } child_set_tid = em->child_set_tid; EMUL_UNLOCK(&emul_lock); @@ -1391,12 +1364,7 @@ /* find the emuldata */ em = em_find(td->td_proc, EMUL_UNLOCKED); - if (em == NULL) { -#ifdef DEBUG - printf(LMSG("we didnt find emuldata for the userreting process.\n")); -#endif - return (0); - } + KASSERT(em != NULL, ("set_tid_address: emuldata not found.\n")); em->child_clear_tid = args->tidptr; td->td_retval[0] = td->td_proc->p_pid; @@ -1418,12 +1386,7 @@ td_em = em_find(td->td_proc, EMUL_UNLOCKED); - if (td_em == NULL) { -#ifdef DEBUG - printf(LMSG("we didnt find emuldata in exit_group.")); -#endif - return (0); - } + KASSERT(td_em != NULL, ("exit_group: emuldata not found.\n")); EMUL_SHARED_RLOCK(&emul_shared_lock); LIST_FOREACH_SAFE(em, &td_em->shared->threads, threads, tmp_em) {