attach_pid() with struct pid parameter

attach_pid() currently takes a pid_t and then uses find_pid() to find the
corresponding struct pid.  Sometimes we already have the struct pid.  We can
then skip find_pid() if attach_pid() were to take a struct pid parameter.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: <containers@lists.osdl.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Sukadev Bhattiprolu 2007-05-10 22:22:58 -07:00 committed by Linus Torvalds
parent 4ac24b3ba9
commit e713d0dab2
6 changed files with 18 additions and 13 deletions

View file

@ -247,13 +247,16 @@ struct pid * fastcall find_pid(int nr)
}
EXPORT_SYMBOL_GPL(find_pid);
int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr)
/*
* attach_pid() must be called with the tasklist_lock write-held.
*/
int fastcall attach_pid(struct task_struct *task, enum pid_type type,
struct pid *pid)
{
struct pid_link *link;
struct pid *pid;
link = &task->pids[type];
link->pid = pid = find_pid(nr);
link->pid = pid;
hlist_add_head_rcu(&link->node, &pid->tasks[type]);
return 0;