mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] reduce reparent_to_init()
@ 2007-04-10 18:50 Oleg Nesterov
  2007-04-10 22:27 ` Eric W. Biederman
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2007-04-10 18:50 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Davide Libenzi, Eric W. Biederman, Jan Engelhardt, Ingo Molnar,
	Linus Torvalds, Robin Holt, Roland McGrath, Serge E. Hallyn,
	linux-kernel

Move some random stuff which doesn't need tasklist_lock from reparent_to_init()
to its caller, daemonize(). Strictly speaking, rlim is protected by task_lock()
but we don't need it to copy init_task->rlim.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 2.6.21-rc5/kernel/exit.c~1_REDUCE	2007-04-05 12:18:28.000000000 +0400
+++ 2.6.21-rc5/kernel/exit.c	2007-04-10 21:32:44.000000000 +0400
@@ -271,7 +271,6 @@ static void reparent_to_init(void)
 	write_lock_irq(&tasklist_lock);
 
 	ptrace_unlink(current);
-	/* Reparent to init */
 	remove_parent(current);
 	current->parent = child_reaper(current);
 	current->real_parent = child_reaper(current);
@@ -280,17 +279,8 @@ static void reparent_to_init(void)
 	/* Set the exit signal to SIGCHLD so we signal init on exit */
 	current->exit_signal = SIGCHLD;
 
-	if (!has_rt_policy(current) && (task_nice(current) < 0))
-		set_user_nice(current, 0);
-	/* cpus_allowed? */
-	/* rt_priority? */
-	/* signals? */
 	security_task_reparent_to_init(current);
-	memcpy(current->signal->rlim, init_task.signal->rlim,
-	       sizeof(current->signal->rlim));
-	atomic_inc(&(INIT_USER->__count));
 	write_unlock_irq(&tasklist_lock);
-	switch_uid(INIT_USER);
 }
 
 void __set_special_pids(pid_t session, pid_t pgrp)
@@ -402,6 +392,17 @@ void daemonize(const char *name, ...)
 	atomic_inc(&current->files->count);
 
 	reparent_to_init();
+
+	if (!has_rt_policy(current) && (task_nice(current) < 0))
+		set_user_nice(current, 0);
+	/* cpus_allowed? */
+	/* rt_priority? */
+	/* signals? */
+	memcpy(current->signal->rlim, init_task.signal->rlim,
+	       sizeof(current->signal->rlim));
+
+	atomic_inc(&(INIT_USER->__count));
+	switch_uid(INIT_USER);
 }
 
 EXPORT_SYMBOL(daemonize);


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

* Re: [PATCH 1/3] reduce reparent_to_init()
  2007-04-10 18:50 [PATCH 1/3] reduce reparent_to_init() Oleg Nesterov
@ 2007-04-10 22:27 ` Eric W. Biederman
  0 siblings, 0 replies; 2+ messages in thread
From: Eric W. Biederman @ 2007-04-10 22:27 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Andrew Morton, Davide Libenzi, Jan Engelhardt, Ingo Molnar,
	Linus Torvalds, Robin Holt, Roland McGrath, Serge E. Hallyn,
	linux-kernel

Oleg Nesterov <oleg@tv-sign.ru> writes:

> Move some random stuff which doesn't need tasklist_lock from reparent_to_init()
> to its caller, daemonize(). Strictly speaking, rlim is protected by task_lock()
> but we don't need it to copy init_task->rlim.

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>

Regardless of whatever else we are doing getting junk out of a function
whose goal is to reparent a kernel thread makes sense.

Eric

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

end of thread, other threads:[~2007-04-10 22:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-10 18:50 [PATCH 1/3] reduce reparent_to_init() Oleg Nesterov
2007-04-10 22:27 ` Eric W. Biederman

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

Powered by JetHome