patch to fix SMP vkernel reboots

Joerg Sonnenberger joerg at britannica.bec.de
Thu Jul 12 09:17:06 PDT 2007


On Thu, Jul 12, 2007 at 11:32:43AM -0400, Joe Talbott wrote:
> 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.

I would suggest a few modifications:
(1) Use SIGTERM. It is common to have that meaning.
(2) Memorize the original thread in a global variable. Set a second one
to notify that it was called internally.
(3) In the signal handler, check if the second variable is called. If
not, handle this as external shutdown/reboot request. If it is, compare
pthread_self() with the first variable and pthread_exit() if they don't
match. Use a conditional variable to find out when all threads are dead.

Ideally this dance would not be necessary as exec is supposed to kill
all LWPs.

Joerg





More information about the Submit mailing list