use CLONE_KERNEL_THREAD
RFC PATCH 3/3 use CLONE_KERNEL_THREAD
For review only.
Add CLONE_KERNEL_THREAD to kthread_create() and change reparent_to_init() to match CLONE_KERNEL_THREAD.
Signed-off-by Oleg Nesterov <[email protected]>
kthread.c | 2 +- exit.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-)
kernel/kthread.c renamed from kernel/kthread.c~3_USE +1 -1
@@ -120,7 +120,7 @@ static void keventd_create_kthread(strucint pid;/* We want our own signal handler (we take no signals by default). */ - pid =kernel_thread (kthread, create,CLONE_FS |CLONE_FILES |SIGCHLD ); + pid =kernel_thread (kthread, create,CLONE_FS |CLONE_FILES |CLONE_KERNEL_THREAD );if (pid <0 ) { create->result =ERR_PTR (pid); }else {
kernel/exit.c renamed from kernel/exit.c~3_USE +9 -11
@@ -279,28 +279,26 @@ static int has_stopped_jobs(struct pid * }/** -* reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to. +* reparent_kthread - Reparent the calling kernel thread to swapper. * * If a kernel thread is launched as a result of a system call, or if -* it ever exits, it should generally reparent itself to init so that -* it is correctly cleaned up on exit. +* it ever exits, it should generally reparent itself so that it is +* correctly cleaned up on exit. * * The various task state such as scheduling policy and priority may have * been inherited from a user process, so we reset them to sane values here. * -* NOTE that reparent_to_init() gives the caller full capabilities. +* NOTE that reparent_kthread() gives the caller full capabilities. */ -static void reparent_to_init (void ) +static void reparent_kthread (void ) {write_lock_irq (&tasklist_lock); -/* Reparent to init */ remove_parent (current); - current->parent =child_reaper (current); -add_parent (current); -/* Set the exit signal to SIGCHLD so we signal init on exit */ - current->exit_signal =SIGCHLD ; + current->parent = &init_task; +add_parent (current); + current->exit_signal =-1 ;if (!has_rt_policy (current) && (task_nice (current) <0 ))set_user_nice (current,0 );
@@ -423,7 +421,7 @@ void daemonize(const char *name, ...) current->files = init_task.files;atomic_inc (¤t->files->count); -reparent_to_init (); +reparent_kthread (); }EXPORT_SYMBOL (daemonize);
Quoted 35 lines · Oleg Nesterov
For review only.
Add
CLONE_KERNEL_THREADtokthread_create()and changereparent_to_init()to matchCLONE_KERNEL_THREAD.Signed-off-by Oleg Nesterov <[email protected]>kthread.c | 2 +- exit.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-)kernel/kthread.c renamed from kernel/kthread.c~3_USE +1
-1@@ -120,7 +120,7 @@ static void keventd_create_kthread(strucint pid;/* We want our own signal handler (we take no signals by default). */ - pid =kernel_thread (kthread, create,CLONE_FS |CLONE_FILES |SIGCHLD ); + pid =kernel_thread (kthread, create,CLONE_FS |CLONE_FILES |CLONE_KERNEL_THREAD );if (pid <0 ) { create->result =ERR_PTR (pid); }else {kernel/exit.c renamed from kernel/exit.c~3_USE +2
-3@@ -279,28 +279,26 @@ static int has_stopped_jobs(struct pid * }/** -* reparent_to_init - Reparent the calling kernel thread to the init task of the pid space that the thread belongs to. +* reparent_kthread - Reparent the calling kernel thread to swapper. * * If a kernel thread is launched as a result of a system call, or if -* it ever exits, it should generally reparent itself to init so that -* it is correctly cleaned up on exit. +* it ever exits, it should generally reparent itself so that it is
kernel/exit.c static int has_stopped_jobs(struct pid * · line 293
Quoted 10 lines
kernel/exit.c renamed from kernel/exit.c~3_USE +3
-2+* correctly cleaned up on exit. * * The various task state such as scheduling policy and priority may have * been inherited from a user process, so we reset them to sane values here. * -* NOTE that reparent_to_init() gives the caller full capabilities. +* NOTE that reparent_kthread() gives the caller full capabilities. */ -static void reparent_to_init (void ) +static void reparent_kthread (void )
Thanks. The use of 'child_reaper(current)' makes it clear that 'reparent_to_init' had turned into a confusing name in the name of per-pidspace inits.
-serge
Quoted 31 lines
kernel/exit.c renamed from kernel/exit.c~3_USE +4
-7{write_lock_irq (&tasklist_lock); -/* Reparent to init */ remove_parent (current); - current->parent =child_reaper (current); -add_parent (current); -/* Set the exit signal to SIGCHLD so we signal init on exit */ - current->exit_signal =SIGCHLD ; + current->parent = &init_task; +add_parent (current); + current->exit_signal =-1 ;if (!has_rt_policy (current) && (task_nice (current) <0 ))set_user_nice (current,0 );@@ -423,7 +421,7 @@ void daemonize(const char *name, ...) current->files = init_task.files;atomic_inc (¤t->files->count); -reparent_to_init (); +reparent_kthread (); }EXPORT_SYMBOL (daemonize); -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/