public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/5] Use task_pid() to find leader's pid
@ 2007-07-15  4:57 sukadev
  0 siblings, 0 replies; 4+ messages in thread
From: sukadev @ 2007-07-15  4:57 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel
  Cc: Pavel Emelianov, serue, clg, haveblue, Containers


Subject: [PATCH 3/5] Use task_pid() to find leader's pid

From: Sukadev Bhattiprolu <sukadev@us.ibm.com>

Use task_pid() to get leader's pid since find_pid() cannot be used
after detach_pid(). See comments in the code below for more details.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Acked-by: Pavel Emelianov <xemul@openvz.org>

Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Herbert Poetzel <herbert@13thfloor.at>
---
 fs/exec.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: lx26-22-rc6-mm1/fs/exec.c
===================================================================
--- lx26-22-rc6-mm1.orig/fs/exec.c	2007-07-13 13:12:01.000000000 -0700
+++ lx26-22-rc6-mm1/fs/exec.c	2007-07-13 13:12:13.000000000 -0700
@@ -905,10 +905,17 @@ static int de_thread(struct task_struct 
 		 * The old leader becomes a thread of the this thread group.
 		 * Note: The old leader also uses this pid until release_task
 		 *       is called.  Odd but simple and correct.
+		 * Note: With multiple pid namespaces, active pid namespace of
+		 * 	 a process is stored in its struct pid. The detach_pid
+		 * 	 below frees the struct pid, so we will have no notion
+		 * 	 of an active pid namespace until we complete the
+		 * 	 subsequent attach_pid(). Which means - calls like
+		 * 	 find_pid()/pid_to_nr() return NULL and cannot be used
+		 * 	 between the detach_pid() and attach_pid() calls.
 		 */
 		detach_pid(tsk, PIDTYPE_PID);
 		tsk->pid = leader->pid;
-		attach_pid(tsk, PIDTYPE_PID,  find_pid(tsk->pid));
+		attach_pid(tsk, PIDTYPE_PID,  task_pid(leader));
 		transfer_pid(leader, tsk, PIDTYPE_PGID);
 		transfer_pid(leader, tsk, PIDTYPE_SID);
 		list_replace_rcu(&leader->tasks, &tsk->tasks);

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [PATCH 3/5] Use task_pid() to find leader's pid
@ 2007-07-15 12:17 Oleg Nesterov
  2007-07-16 19:59 ` sukadev
  0 siblings, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2007-07-15 12:17 UTC (permalink / raw)
  To: Sukadev Bhattiprolu
  Cc: Andrew Morton, Eric W. Biederman, Cedric Le Goater, Dave Hansen,
	Serge Hallyn, Herbert Poetzel, Pavel Emelianov, Linux Containers,
	linux-kernel

Sukadev Bhattiprolu wrote:
>
> Use task_pid() to get leader's pid since find_pid() cannot be used
> after detach_pid(). See comments in the code below for more details.
>
> ...
>
> +		 * Note: With multiple pid namespaces, active pid namespace of
> +		 * 	 a process is stored in its struct pid. The detach_pid
> +		 * 	 below frees the struct pid, so we will have no notion
> +		 * 	 of an active pid namespace until we complete the
> +		 * 	 subsequent attach_pid(). Which means - calls like
> +		 * 	 find_pid()/pid_to_nr() return NULL and cannot be used
> +		 * 	 between the detach_pid() and attach_pid() calls.

I think both the changelog and the comment are confusing,

>  		detach_pid(tsk, PIDTYPE_PID);
>  		tsk->pid = leader->pid;
> -		attach_pid(tsk, PIDTYPE_PID,  find_pid(tsk->pid));
> +		attach_pid(tsk, PIDTYPE_PID,  task_pid(leader));

because the change itself looks like an obvious performance fix, even
we don't use multiple pid namespaces. I don't think it is good idea to
add a fat comment which doesn't match the current reality, and find_pid()
should be avoided anyway.

Stupid question: why do we need to put the pid namespace into the struct
pid? Isn't it better if the user of the struct pid should know its ns?
For example, if /proc does put_pid(), that pid should be from the active
namespace.

Sukadev, could you cc me if you do that kind of changes?

Oleg.


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

end of thread, other threads:[~2007-07-17 13:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-15  4:57 [PATCH 3/5] Use task_pid() to find leader's pid sukadev
  -- strict thread matches above, loose matches on Subject: below --
2007-07-15 12:17 Oleg Nesterov
2007-07-16 19:59 ` sukadev
2007-07-17 13:44   ` Oleg Nesterov

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