Silly kernel hacking

From: Eric Roman (eroman_at_lbl.gov)
Date: Fri Jun 21 2002 - 20:53:08 PDT


So I just wrote an ioctl() that returns twice.  Ha!

Anyway, I was under the delusion that do_fork() might actually copy the kernel
stack as well as the user stack so that I could 

if (do_fork() == 0) {
  vmadump_thaw_proc()
}

Silly me.  So the fun thing here is that do_fork() only returns to kernel
space on the parent side.  The newly created process is left running right
after the fork().

Given that, the user space restart code might have to look something like

if (ioctl(CR_IOCTL_RSTRT_REQ) == 0) {
  ioctl(CR_IOCTL_RSTRT_CHILD)
}

Fun, eh?

Or worse, we could require user space to be responsible for all process
creation.  I find this solution to be a little bit more icky.  It forces us
to do something like

while ((ioctl(CR_IOCTL_RSTRT_SHOULD_I_FORK)) == 1) {
  if (fork() == 0) {
    ioctl(CR_IOCTL_RSTRT_CHILD)
    break;
  }
}

I like this less, because it involves quite a lot of juggling between the
restart process and the kernel, and isn't exactly what I'd call a clean
interface.

Other alternatives?  Re-implement fork?  Sounds even worse to me.  

So, I'm partial to the first approach.  

-- 
Eric Roman  <eroman_at_lbl_dot_gov>     Future Technologies Group
510-486-6420                     Lawrence Berkeley National Laboratory