diff options
author | Sukadev Bhattiprolu <sukadev@us.ibm.com> | 2007-05-11 01:22:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:35 -0400 |
commit | e713d0dab21a68500720e222fa02567fc7dfb14b (patch) | |
tree | a56f90ce94d9287b73da6db72ed0e73542a70a07 /kernel | |
parent | 4ac24b3ba9016881b11646114bb5cd12cf23edd9 (diff) |
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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 4 | ||||
-rw-r--r-- | kernel/fork.c | 11 | ||||
-rw-r--r-- | kernel/pid.c | 9 | ||||
-rw-r--r-- | kernel/sys.c | 2 |
4 files changed, 16 insertions, 10 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 7a5fd77f8fb0..e93691e9b325 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -302,12 +302,12 @@ void __set_special_pids(pid_t session, pid_t pgrp) | |||
302 | if (process_session(curr) != session) { | 302 | if (process_session(curr) != session) { |
303 | detach_pid(curr, PIDTYPE_SID); | 303 | detach_pid(curr, PIDTYPE_SID); |
304 | set_signal_session(curr->signal, session); | 304 | set_signal_session(curr->signal, session); |
305 | attach_pid(curr, PIDTYPE_SID, session); | 305 | attach_pid(curr, PIDTYPE_SID, find_pid(session)); |
306 | } | 306 | } |
307 | if (process_group(curr) != pgrp) { | 307 | if (process_group(curr) != pgrp) { |
308 | detach_pid(curr, PIDTYPE_PGID); | 308 | detach_pid(curr, PIDTYPE_PGID); |
309 | curr->signal->pgrp = pgrp; | 309 | curr->signal->pgrp = pgrp; |
310 | attach_pid(curr, PIDTYPE_PGID, pgrp); | 310 | attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp)); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
diff --git a/kernel/fork.c b/kernel/fork.c index da92e01aba6b..6031800c94cf 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1249,16 +1249,19 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1249 | __ptrace_link(p, current->parent); | 1249 | __ptrace_link(p, current->parent); |
1250 | 1250 | ||
1251 | if (thread_group_leader(p)) { | 1251 | if (thread_group_leader(p)) { |
1252 | pid_t pgid = process_group(current); | ||
1253 | pid_t sid = process_session(current); | ||
1254 | |||
1252 | p->signal->tty = current->signal->tty; | 1255 | p->signal->tty = current->signal->tty; |
1253 | p->signal->pgrp = process_group(current); | 1256 | p->signal->pgrp = pgid; |
1254 | set_signal_session(p->signal, process_session(current)); | 1257 | set_signal_session(p->signal, process_session(current)); |
1255 | attach_pid(p, PIDTYPE_PGID, process_group(p)); | 1258 | attach_pid(p, PIDTYPE_PGID, find_pid(pgid)); |
1256 | attach_pid(p, PIDTYPE_SID, process_session(p)); | 1259 | attach_pid(p, PIDTYPE_SID, find_pid(sid)); |
1257 | 1260 | ||
1258 | list_add_tail_rcu(&p->tasks, &init_task.tasks); | 1261 | list_add_tail_rcu(&p->tasks, &init_task.tasks); |
1259 | __get_cpu_var(process_counts)++; | 1262 | __get_cpu_var(process_counts)++; |
1260 | } | 1263 | } |
1261 | attach_pid(p, PIDTYPE_PID, p->pid); | 1264 | attach_pid(p, PIDTYPE_PID, find_pid(p->pid)); |
1262 | nr_threads++; | 1265 | nr_threads++; |
1263 | } | 1266 | } |
1264 | 1267 | ||
diff --git a/kernel/pid.c b/kernel/pid.c index d3ad724afa83..d76f59326bd4 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -247,13 +247,16 @@ struct pid * fastcall find_pid(int nr) | |||
247 | } | 247 | } |
248 | EXPORT_SYMBOL_GPL(find_pid); | 248 | EXPORT_SYMBOL_GPL(find_pid); |
249 | 249 | ||
250 | int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr) | 250 | /* |
251 | * attach_pid() must be called with the tasklist_lock write-held. | ||
252 | */ | ||
253 | int fastcall attach_pid(struct task_struct *task, enum pid_type type, | ||
254 | struct pid *pid) | ||
251 | { | 255 | { |
252 | struct pid_link *link; | 256 | struct pid_link *link; |
253 | struct pid *pid; | ||
254 | 257 | ||
255 | link = &task->pids[type]; | 258 | link = &task->pids[type]; |
256 | link->pid = pid = find_pid(nr); | 259 | link->pid = pid; |
257 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); | 260 | hlist_add_head_rcu(&link->node, &pid->tasks[type]); |
258 | 261 | ||
259 | return 0; | 262 | return 0; |
diff --git a/kernel/sys.c b/kernel/sys.c index df4c3a8f5df9..872271ccc384 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1488,7 +1488,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid) | |||
1488 | if (process_group(p) != pgid) { | 1488 | if (process_group(p) != pgid) { |
1489 | detach_pid(p, PIDTYPE_PGID); | 1489 | detach_pid(p, PIDTYPE_PGID); |
1490 | p->signal->pgrp = pgid; | 1490 | p->signal->pgrp = pgid; |
1491 | attach_pid(p, PIDTYPE_PGID, pgid); | 1491 | attach_pid(p, PIDTYPE_PGID, find_pid(pgid)); |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | err = 0; | 1494 | err = 0; |