public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC, PATCH 3/3] use CLONE_KERNEL_THREAD
@ 2007-04-08 15:55 Oleg Nesterov
  2007-04-09 16:19 ` Serge E. Hallyn
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2007-04-08 15:55 UTC (permalink / raw)
  To: Andrew Morton, Eric W. Biederman, Davide Libenzi, Ingo Molnar,
	Linus Torvalds, Robin Holt, Roland McGrath
  Cc: linux-kernel, linux-arch

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 <oleg@tv-sign.ru>

 kthread.c |    2 +-
 exit.c    |   20 +++++++++-----------
 2 files changed, 10 insertions(+), 12 deletions(-)

--- 2.6.21-rc5-mm4/kernel/kthread.c~3_USE	2007-04-05 12:18:28.000000000 +0400
+++ 2.6.21-rc5-mm4/kernel/kthread.c	2007-04-08 19:18:59.000000000 +0400
@@ -120,7 +120,7 @@ static void keventd_create_kthread(struc
 	int 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 {
--- 2.6.21-rc5-mm4/kernel/exit.c~3_USE	2007-04-08 19:06:27.000000000 +0400
+++ 2.6.21-rc5-mm4/kernel/exit.c	2007-04-08 19:23:18.000000000 +0400
@@ -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(&current->files->count);
 
-	reparent_to_init();
+	reparent_kthread();
 }
 
 EXPORT_SYMBOL(daemonize);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC, PATCH 3/3] use CLONE_KERNEL_THREAD
  2007-04-08 15:55 [RFC, PATCH 3/3] use CLONE_KERNEL_THREAD Oleg Nesterov
@ 2007-04-09 16:19 ` Serge E. Hallyn
  0 siblings, 0 replies; 2+ messages in thread
From: Serge E. Hallyn @ 2007-04-09 16:19 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Eric W. Biederman, Davide Libenzi, Ingo Molnar,
	Linus Torvalds, Robin Holt, Roland McGrath, linux-kernel,
	linux-arch

Quoting Oleg Nesterov (oleg@tv-sign.ru):
> 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 <oleg@tv-sign.ru>
> 
>  kthread.c |    2 +-
>  exit.c    |   20 +++++++++-----------
>  2 files changed, 10 insertions(+), 12 deletions(-)
> 
> --- 2.6.21-rc5-mm4/kernel/kthread.c~3_USE	2007-04-05 12:18:28.000000000 +0400
> +++ 2.6.21-rc5-mm4/kernel/kthread.c	2007-04-08 19:18:59.000000000 +0400
> @@ -120,7 +120,7 @@ static void keventd_create_kthread(struc
>  	int 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 {
> --- 2.6.21-rc5-mm4/kernel/exit.c~3_USE	2007-04-08 19:06:27.000000000 +0400
> +++ 2.6.21-rc5-mm4/kernel/exit.c	2007-04-08 19:23:18.000000000 +0400
> @@ -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)

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

>  {
>  	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(&current->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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-04-09 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-08 15:55 [RFC, PATCH 3/3] use CLONE_KERNEL_THREAD Oleg Nesterov
2007-04-09 16:19 ` Serge E. Hallyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox