is a task_struct vfork_done completion special only for kthreads?

Mulyadi Santosa mulyadi.santosa at
Fri Jun 15 23:08:35 EDT 2012

Hi Rob...

On Thu, Jun 14, 2012 at 7:03 PM, Robert P. J. Day <rpjday at> wrote:
>  (what is probably the first in a plethora of silly questions as i
> dig into the ugly details of various kernel features.  you've been
> warned.)
>  clawing my way through the kernel code for kthreads and i notice the
> following.  in kernel/kthread.c, we have:
> ===
> struct kthread {
>        int should_stop;
>        void *data;
>        struct completion exited;
> };
> #define to_kthread(tsk) \
>        container_of((tsk)->vfork_done, struct kthread, exited)

perhaps because somehow kernel thread in some ways are treated like
normal vfork()?

the way I see it is this:
kernel thread borrows previously running mm_struct. In this scope, if
somehow the real owner mm_struct is going to be destroyed, it must
wait for the borrower (kernel thread) to finish first. Maybe this is
where that vfork_done<-->exited correlation is used.


Mulyadi Santosa
Freelance Linux trainer and consultant


More information about the Kernelnewbies mailing list