Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Oct 2006 15:39:25 GMT
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 107900 for review
Message-ID:  <200610141539.k9EFdPmG035282@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=107900

Change 107900 by rdivacky@rdivacky_witten on 2006/10/14 15:38:47

	Rewritten, yet still panicing version of pdeath_signal.

Affected files ...

.. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysvec.c#3 edit
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_emul.c#9 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#7 edit
.. //depot/projects/linuxolator/src/sys/i386/linux/linux_sysvec.c#3 edit
.. //depot/projects/linuxolator/src/sys/kern/kern_exit.c#5 edit
.. //depot/projects/linuxolator/src/sys/sys/eventhandler.h#3 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_sysvec.c#3 (text+ko) ====

@@ -129,7 +129,6 @@
 static eventhandler_tag linux_exit_tag;
 static eventhandler_tag linux_schedtail_tag;
 static eventhandler_tag linux_exec_tag;
-static eventhandler_tag linux_reparent_tag;
 
 /*
  * Linux syscalls return negative errno's, we do positive and map them
@@ -1088,8 +1087,6 @@
 			      NULL, 1000);
 			linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
 			      NULL, 1000);
-			linux_reparent_tag = EVENTHANDLER_REGISTER(reparent, linux_reparent,
-			      NULL, 1000);
 			if (bootverbose)
 				printf("Linux ELF exec handler installed\n");
 		} else
@@ -1117,7 +1114,6 @@
 			EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
 			EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag);
 			EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
-			EVENTHANDLER_DEREGISTER(reparent, linux_reparent_tag);
 			if (bootverbose)
 				printf("Linux ELF exec handler removed\n");
 		} else

==== //depot/projects/linuxolator/src/sys/compat/linux/linux_emul.c#9 (text+ko) ====

@@ -152,6 +152,7 @@
 	int error;
 	struct thread *td = FIRST_THREAD_IN_PROC(p);
 	int *child_clear_tid;
+	struct proc *q, *nq;
 
 	if (__predict_true(p->p_sysent != &elf_linux_sysvec))
 	   	return;
@@ -205,6 +206,24 @@
 
 	/* clean the stuff up */
 	free(em, M_LINUX);
+
+	/* this is a little weird but rewritten from exit1() */
+	sx_xlock(&proctree_lock);
+	q = LIST_FIRST(&p->p_children);
+	for (; q != NULL; q = nq) {
+	   	nq = LIST_NEXT(q, p_sibling);
+		if (__predict_true(q->p_sysent != &elf_linux_sysvec))
+   		   	break;
+   	   	em = em_find(q, EMUL_UNLOCKED);
+		KASSERT(em != NULL, ("linux_reparent: emuldata not found: %i\n", q->p_pid));
+		if (em->pdeath_signal != 0) {
+   		   	PROC_LOCK(q);
+   		   	psignal(q, em->pdeath_signal);
+			PROC_UNLOCK(q);
+		}
+		EMUL_UNLOCK(&emul_lock);
+	}
+	sx_xunlock(&proctree_lock);
 }
 
 /* 
@@ -300,22 +319,3 @@
 	EMUL_UNLOCK(&emul_lock);
 	return 0;
 }
-
-/* p is locked */
-void
-linux_reparent(void *arg __unused, struct proc *p)
-{
-   	struct linux_emuldata *em;
-
-	if (__predict_true(p->p_sysent != &elf_linux_sysvec))
-	   	return;
-
-	/* do this only if the parent is exiting */
-	if (p->p_pptr->p_flag & P_WEXIT) {
-   	   	em = em_find(p, EMUL_UNLOCKED);
-		KASSERT(em != NULL, ("linux_reparent: emuldata not found.\n"));
-		if (em->pdeath_signal != 0)
-   		   	psignal(p, em->pdeath_signal);
-		EMUL_UNLOCK(&emul_lock);
-	}
-}

==== //depot/projects/linuxolator/src/sys/i386/linux/linux_machdep.c#7 (text+ko) ====


==== //depot/projects/linuxolator/src/sys/i386/linux/linux_sysvec.c#3 (text+ko) ====

@@ -113,7 +113,6 @@
 static eventhandler_tag linux_exit_tag;
 static eventhandler_tag linux_schedtail_tag;
 static eventhandler_tag linux_exec_tag;
-static eventhandler_tag linux_reparent_tag;
 
 /*
  * Linux syscalls return negative errno's, we do positive and map them
@@ -928,8 +927,6 @@
 			      NULL, 1000);
 			linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
 			      NULL, 1000);
-			linux_reparent_tag = EVENTHANDLER_REGISTER(reparent, linux_reparent,
-			      NULL, 1000);
 			if (bootverbose)
 				printf("Linux ELF exec handler installed\n");
 		} else
@@ -957,7 +954,6 @@
 			EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
 			EVENTHANDLER_DEREGISTER(schedtail, linux_schedtail_tag);
 			EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
-			EVENTHANDLER_DEREGISTER(reparent, linux_reparent_tag);
 			if (bootverbose)
 				printf("Linux ELF exec handler removed\n");
 		} else

==== //depot/projects/linuxolator/src/sys/kern/kern_exit.c#5 (text+ko) ====

@@ -897,9 +897,6 @@
 	if (child->p_pptr == parent)
 		return;
 
-	/* we want to have old parent accessible via p_pptr */
-	EVENTHANDLER_INVOKE(reparent, child);
-
 	LIST_REMOVE(child, p_sibling);
 	LIST_INSERT_HEAD(&parent->p_children, child, p_sibling);
 	child->p_pptr = parent;

==== //depot/projects/linuxolator/src/sys/sys/eventhandler.h#3 (text+ko) ====

@@ -179,6 +179,4 @@
 typedef void(*schedtail_fn)(void *, struct proc *);
 EVENTHANDLER_DECLARE(schedtail, schedtail_fn);
 
-typedef void(*reparent_fn)(void *, struct proc *);
-EVENTHANDLER_DECLARE(reparent, reparent_fn);
 #endif /* SYS_EVENTHANDLER_H */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610141539.k9EFdPmG035282>