DragonFly submit List (threaded) for 2007-07
DragonFly BSD
DragonFly submit List (threaded) for 2007-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

patch to fix SMP vkernel reboots


From: Joe Talbott <josepht@xxxxxxxxxx>
Date: Thu, 12 Jul 2007 11:32:43 -0400
Mail-followup-to: "submit@crater.dragonflybsd.org" <submit@crater.dragonflybsd.org>

Rebooting an SMP vkernel currently doesn't work since kern_execve()
won't exec if multiple LWPs are present.  The attached patch adds a
signal handler for SIGUSR2 which calls pthread_exit() on the current
thread and a function kill_vcpus() that sends SIGUSR2 to each of the
virtual CPU threads.  I'm not sure if I need to do some memory
clean-up or not, so let me know if I'm missing something.

Joe
Index: sys/platform/vkernel/i386/exception.c
===================================================================
RCS file: /home/dcvs/src/sys/platform/vkernel/i386/exception.c,v
retrieving revision 1.8
diff -u -r1.8 exception.c
--- sys/platform/vkernel/i386/exception.c	1 Jul 2007 03:04:14 -0000	1.8
+++ sys/platform/vkernel/i386/exception.c	12 Jul 2007 15:24:31 -0000
@@ -85,6 +85,15 @@
 	--mycpu->gd_intr_nesting_level;
 }
 
+static
+void
+halt_vcpu(int nada, siginfo_t *info, void *ctxp)
+{
+	int ret = 0;
+
+	pthread_exit(&ret);
+}
+
 #endif
 
 void
@@ -106,6 +115,8 @@
 #ifdef SMP
 	sa.sa_sigaction = ipisig;
 	sigaction(SIGUSR1, &sa, NULL);
+	sa.sa_sigaction = halt_vcpu;
+	sigaction(SIGUSR2, &sa, NULL);
 #endif
 }
 
Index: sys/platform/vkernel/i386/mp.c
===================================================================
RCS file: /home/dcvs/src/sys/platform/vkernel/i386/mp.c,v
retrieving revision 1.6
diff -u -r1.6 mp.c
--- sys/platform/vkernel/i386/mp.c	10 Jul 2007 18:35:38 -0000	1.6
+++ sys/platform/vkernel/i386/mp.c	12 Jul 2007 15:24:48 -0000
@@ -455,3 +455,17 @@
 
 	return(ncpus - 1);
 }
+
+#ifdef SMP
+
+void
+kill_cpus(void)
+{
+	int i;
+
+	for (i = 1; i < MAXCPU; i++)
+		if (ap_tids[i] != NULL)
+			pthread_kill(ap_tids[i], SIGUSR2);
+}
+
+#endif
Index: sys/platform/vkernel/include/smp.h
===================================================================
RCS file: /home/dcvs/src/sys/platform/vkernel/include/smp.h,v
retrieving revision 1.3
diff -u -r1.3 smp.h
--- sys/platform/vkernel/include/smp.h	2 Jul 2007 02:37:04 -0000	1.3
+++ sys/platform/vkernel/include/smp.h	12 Jul 2007 15:37:35 -0000
@@ -123,6 +123,7 @@
 int	stop_cpus		(u_int);
 void	ap_init			(void);
 int	restart_cpus		(u_int);
+void	kill_cpus		(void);
 #if 0
 void	forward_signal		(struct proc *);
 
Index: sys/platform/vkernel/platform/init.c
===================================================================
RCS file: /home/dcvs/src/sys/platform/vkernel/platform/init.c,v
retrieving revision 1.44
diff -u -r1.44 init.c
--- sys/platform/vkernel/platform/init.c	10 Jul 2007 18:35:38 -0000	1.44
+++ sys/platform/vkernel/platform/init.c	12 Jul 2007 15:37:08 -0000
@@ -54,6 +54,7 @@
 
 #include <machine/cpu.h>
 #include <machine/globaldata.h>
+#include <machine/smp.h>
 #include <machine/tls.h>
 #include <machine/md_var.h>
 #include <machine/vmparam.h>
@@ -1148,6 +1149,9 @@
 	kprintf("cpu reset, rebooting vkernel\n");
 	closefrom(3);
 	cleanpid();
+#ifdef SMP
+	kill_cpus();
+#endif
 	execv(save_av[0], save_av);
 }
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]