diff options
author | Sukadev Bhattiprolu <sukadev@us.ibm.com> | 2007-05-11 01:23:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:35 -0400 |
commit | 85868995d9d82de5b0de38d695559daddffef893 (patch) | |
tree | d66d265a14739e2c622c8e3ce507e09ffc5200fb /kernel/fork.c | |
parent | 0e29b24aa6b3eb6c161cbb9e42fc20b47e67a7c6 (diff) |
Use struct pid parameter in copy_process()
Modify copy_process() to take a struct pid * parameter instead of a pid_t.
This simplifies the code a bit and also avoids having to call find_pid() to
convert the pid_t to a struct pid.
Changelog:
- Fixed Badari Pulavarty's comments and passed in &init_struct_pid
from fork_idle().
- Fixed Eric Biederman's comments and simplified this patch and
used a new patch to remove the likely(pid) check.
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: Eric Biederman <ebiederm@xmission.com>
Cc: <containers@lists.osdl.org>
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 6031800c94cf..cf13c44f3da3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -956,7 +956,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
956 | unsigned long stack_size, | 956 | unsigned long stack_size, |
957 | int __user *parent_tidptr, | 957 | int __user *parent_tidptr, |
958 | int __user *child_tidptr, | 958 | int __user *child_tidptr, |
959 | int pid) | 959 | struct pid *pid) |
960 | { | 960 | { |
961 | int retval; | 961 | int retval; |
962 | struct task_struct *p = NULL; | 962 | struct task_struct *p = NULL; |
@@ -1023,7 +1023,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1023 | p->did_exec = 0; | 1023 | p->did_exec = 0; |
1024 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ | 1024 | delayacct_tsk_init(p); /* Must remain after dup_task_struct() */ |
1025 | copy_flags(clone_flags, p); | 1025 | copy_flags(clone_flags, p); |
1026 | p->pid = pid; | 1026 | p->pid = pid_nr(pid); |
1027 | retval = -EFAULT; | 1027 | retval = -EFAULT; |
1028 | if (clone_flags & CLONE_PARENT_SETTID) | 1028 | if (clone_flags & CLONE_PARENT_SETTID) |
1029 | if (put_user(p->pid, parent_tidptr)) | 1029 | if (put_user(p->pid, parent_tidptr)) |
@@ -1261,7 +1261,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1261 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1261 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1262 | __get_cpu_var(process_counts)++; | 1262 | __get_cpu_var(process_counts)++; |
1263 | } | 1263 | } |
1264 | attach_pid(p, PIDTYPE_PID, find_pid(p->pid)); | 1264 | attach_pid(p, PIDTYPE_PID, pid); |
1265 | nr_threads++; | 1265 | nr_threads++; |
1266 | } | 1266 | } |
1267 | 1267 | ||
@@ -1325,7 +1325,8 @@ struct task_struct * __cpuinit fork_idle(int cpu) | |||
1325 | struct task_struct *task; | 1325 | struct task_struct *task; |
1326 | struct pt_regs regs; | 1326 | struct pt_regs regs; |
1327 | 1327 | ||
1328 | task = copy_process(CLONE_VM, 0, idle_regs(®s), 0, NULL, NULL, 0); | 1328 | task = copy_process(CLONE_VM, 0, idle_regs(®s), 0, NULL, NULL, |
1329 | &init_struct_pid); | ||
1329 | if (!IS_ERR(task)) | 1330 | if (!IS_ERR(task)) |
1330 | init_idle(task, cpu); | 1331 | init_idle(task, cpu); |
1331 | 1332 | ||
@@ -1375,7 +1376,7 @@ long do_fork(unsigned long clone_flags, | |||
1375 | clone_flags |= CLONE_PTRACE; | 1376 | clone_flags |= CLONE_PTRACE; |
1376 | } | 1377 | } |
1377 | 1378 | ||
1378 | p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, nr); | 1379 | p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid); |
1379 | /* | 1380 | /* |
1380 | * Do this prior waking up the new thread - the thread pointer | 1381 | * Do this prior waking up the new thread - the thread pointer |
1381 | * might get invalid after that point, if the thread exits quickly. | 1382 | * might get invalid after that point, if the thread exits quickly. |