diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-05-09 02:34:32 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-09 12:30:53 -0700 |
commit | 73c279927f89561ecb45b2dfdf9314bafcfd9f67 (patch) | |
tree | 2186e28c92c6f8229ea20eb9856714186bf77a4c /init/main.c | |
parent | c93465181fed0f8f5942a41108943dadea0aa345 (diff) | |
download | linux-73c279927f89561ecb45b2dfdf9314bafcfd9f67.tar.gz linux-73c279927f89561ecb45b2dfdf9314bafcfd9f67.tar.bz2 linux-73c279927f89561ecb45b2dfdf9314bafcfd9f67.zip |
kthread: don't depend on work queues
Currently there is a circular reference between work queue initialization
and kthread initialization. This prevents the kthread infrastructure from
initializing until after work queues have been initialized.
We want the properties of tasks created with kthread_create to be as close
as possible to the init_task and to not be contaminated by user processes.
The later we start our kthreadd that creates these tasks the harder it is
to avoid contamination from user processes and the more of a mess we have
to clean up because the defaults have changed on us.
So this patch modifies the kthread support to not use work queues but to
instead use a simple list of structures, and to have kthreadd start from
init_task immediately after our kernel thread that execs /sbin/init.
By being a true child of init_task we only have to change those process
settings that we want to have different from init_task, such as our process
name, the cpus that are allowed, blocking all signals and setting SIGCHLD
to SIG_IGN so that all of our children are reaped automatically.
By being a true child of init_task we also naturally get our ppid set to 0
and do not wind up as a child of PID == 1. Ensuring that tasks generated
by kthread_create will not slow down the functioning of the wait family of
functions.
[akpm@linux-foundation.org: use interruptible sleeps]
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/init/main.c b/init/main.c index c1537e0ddceb..e8d080cab443 100644 --- a/init/main.c +++ b/init/main.c @@ -54,6 +54,7 @@ #include <linux/lockdep.h> #include <linux/pid_namespace.h> #include <linux/device.h> +#include <linux/kthread.h> #include <asm/io.h> #include <asm/bugs.h> @@ -425,8 +426,12 @@ static void __init setup_command_line(char *command_line) static void noinline rest_init(void) __releases(kernel_lock) { + int pid; + kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); + pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); + kthreadd_task = find_task_by_pid(pid); unlock_kernel(); /* |