PERFORCE change 103699 for review
Roman Divacky
rdivacky at FreeBSD.org
Sat Aug 12 10:47:49 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103699
Change 103699 by rdivacky at 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) {
More information about the p4-projects
mailing list