From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762507AbXGPUAM (ORCPT ); Mon, 16 Jul 2007 16:00:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758020AbXGPT74 (ORCPT ); Mon, 16 Jul 2007 15:59:56 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:33398 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757982AbXGPT7z (ORCPT ); Mon, 16 Jul 2007 15:59:55 -0400 Date: Mon, 16 Jul 2007 12:59:52 -0700 From: sukadev@us.ibm.com To: Oleg Nesterov , Andrew Morton Cc: "Eric W. Biederman" , Cedric Le Goater , Dave Hansen , Serge Hallyn , Herbert Poetzel , Pavel Emelianov , Linux Containers , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] Use task_pid() to find leader's pid Message-ID: <20070716195952.GG25053@us.ibm.com> References: <20070715121750.GA173@tv-sign.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070715121750.GA173@tv-sign.ru> User-Agent: Mutt/1.4.2.2i X-Operating-System: Linux 2.0.32 on an i486 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov [oleg@tv-sign.ru] wrote: | 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. Its a performance fix but also a correctness issue with multiple pid namespaces. Here is the modified patch with the simplified changelog and comment removed. | | 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. Not sure I fully understand this. A process, and by extension its 'struct pid' is visible in multiple namespaces and we maintain this list of namespaces in each 'struct pid'. Are you suggesting having a pid_namespace with a list of all 'struct pids' that are visible in it ? | | Sukadev, could you cc me if you do that kind of changes? Sure - I will. --- Subject: [PATCH 3/5] Use task_pid() to find leader's pid From: Sukadev Bhattiprolu Use task_pid() to get leader's 'struct pid' and avoid the find_pid(). Signed-off-by: Sukadev Bhattiprolu Acked-by: Pavel Emelianov Cc: Eric W. Biederman Cc: Cedric Le Goater Cc: Dave Hansen Cc: Serge Hallyn Cc: Herbert Poetzel --- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: lx26-22-rc6-mm1a/fs/exec.c =================================================================== --- lx26-22-rc6-mm1a.orig/fs/exec.c 2007-07-13 18:23:55.000000000 -0700 +++ lx26-22-rc6-mm1a/fs/exec.c 2007-07-16 12:56:22.000000000 -0700 @@ -908,7 +908,7 @@ static int de_thread(struct task_struct */ 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);