diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-02-12 03:52:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-12 12:48:32 -0500 |
commit | 0475ac0845f9295bc5f69af45f58dff2c104c8d1 (patch) | |
tree | 2052ddeb6cc271238a1470a2fb3a7082bb1eefd1 /kernel | |
parent | 04a2e6a5cbf84e85fe86de0a18f6509b147e1d89 (diff) |
[PATCH] pid: use struct pid for talking about process groups in exitc
Modify has_stopped_jobs and will_become_orphan_pgrp to use struct pid based
process groups. This reduces the number of hash tables looks ups and paves
the way for multiple pid spaces.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
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 | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 3ac6a7a6f857..407b80aaefda 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -210,22 +210,22 @@ struct pid *session_of_pgrp(struct pid *pgrp) | |||
210 | * | 210 | * |
211 | * "I ask you, have you ever known what it is to be an orphan?" | 211 | * "I ask you, have you ever known what it is to be an orphan?" |
212 | */ | 212 | */ |
213 | static int will_become_orphaned_pgrp(int pgrp, struct task_struct *ignored_task) | 213 | static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task) |
214 | { | 214 | { |
215 | struct task_struct *p; | 215 | struct task_struct *p; |
216 | int ret = 1; | 216 | int ret = 1; |
217 | 217 | ||
218 | do_each_task_pid(pgrp, PIDTYPE_PGID, p) { | 218 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
219 | if (p == ignored_task | 219 | if (p == ignored_task |
220 | || p->exit_state | 220 | || p->exit_state |
221 | || is_init(p->real_parent)) | 221 | || is_init(p->real_parent)) |
222 | continue; | 222 | continue; |
223 | if (process_group(p->real_parent) != pgrp && | 223 | if (task_pgrp(p->real_parent) != pgrp && |
224 | process_session(p->real_parent) == process_session(p)) { | 224 | task_session(p->real_parent) == task_session(p)) { |
225 | ret = 0; | 225 | ret = 0; |
226 | break; | 226 | break; |
227 | } | 227 | } |
228 | } while_each_task_pid(pgrp, PIDTYPE_PGID, p); | 228 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); |
229 | return ret; /* (sighing) "Often!" */ | 229 | return ret; /* (sighing) "Often!" */ |
230 | } | 230 | } |
231 | 231 | ||
@@ -234,23 +234,23 @@ int is_orphaned_pgrp(int pgrp) | |||
234 | int retval; | 234 | int retval; |
235 | 235 | ||
236 | read_lock(&tasklist_lock); | 236 | read_lock(&tasklist_lock); |
237 | retval = will_become_orphaned_pgrp(pgrp, NULL); | 237 | retval = will_become_orphaned_pgrp(find_pid(pgrp), NULL); |
238 | read_unlock(&tasklist_lock); | 238 | read_unlock(&tasklist_lock); |
239 | 239 | ||
240 | return retval; | 240 | return retval; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int has_stopped_jobs(int pgrp) | 243 | static int has_stopped_jobs(struct pid *pgrp) |
244 | { | 244 | { |
245 | int retval = 0; | 245 | int retval = 0; |
246 | struct task_struct *p; | 246 | struct task_struct *p; |
247 | 247 | ||
248 | do_each_task_pid(pgrp, PIDTYPE_PGID, p) { | 248 | do_each_pid_task(pgrp, PIDTYPE_PGID, p) { |
249 | if (p->state != TASK_STOPPED) | 249 | if (p->state != TASK_STOPPED) |
250 | continue; | 250 | continue; |
251 | retval = 1; | 251 | retval = 1; |
252 | break; | 252 | break; |
253 | } while_each_task_pid(pgrp, PIDTYPE_PGID, p); | 253 | } while_each_pid_task(pgrp, PIDTYPE_PGID, p); |
254 | return retval; | 254 | return retval; |
255 | } | 255 | } |
256 | 256 | ||
@@ -648,14 +648,14 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced) | |||
648 | * than we are, and it was the only connection | 648 | * than we are, and it was the only connection |
649 | * outside, so the child pgrp is now orphaned. | 649 | * outside, so the child pgrp is now orphaned. |
650 | */ | 650 | */ |
651 | if ((process_group(p) != process_group(father)) && | 651 | if ((task_pgrp(p) != task_pgrp(father)) && |
652 | (process_session(p) == process_session(father))) { | 652 | (task_session(p) == task_session(father))) { |
653 | int pgrp = process_group(p); | 653 | struct pid *pgrp = task_pgrp(p); |
654 | 654 | ||
655 | if (will_become_orphaned_pgrp(pgrp, NULL) && | 655 | if (will_become_orphaned_pgrp(pgrp, NULL) && |
656 | has_stopped_jobs(pgrp)) { | 656 | has_stopped_jobs(pgrp)) { |
657 | __kill_pg_info(SIGHUP, SEND_SIG_PRIV, pgrp); | 657 | __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp); |
658 | __kill_pg_info(SIGCONT, SEND_SIG_PRIV, pgrp); | 658 | __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp); |
659 | } | 659 | } |
660 | } | 660 | } |
661 | } | 661 | } |
@@ -735,6 +735,7 @@ static void exit_notify(struct task_struct *tsk) | |||
735 | int state; | 735 | int state; |
736 | struct task_struct *t; | 736 | struct task_struct *t; |
737 | struct list_head ptrace_dead, *_p, *_n; | 737 | struct list_head ptrace_dead, *_p, *_n; |
738 | struct pid *pgrp; | ||
738 | 739 | ||
739 | if (signal_pending(tsk) && !(tsk->signal->flags & SIGNAL_GROUP_EXIT) | 740 | if (signal_pending(tsk) && !(tsk->signal->flags & SIGNAL_GROUP_EXIT) |
740 | && !thread_group_empty(tsk)) { | 741 | && !thread_group_empty(tsk)) { |
@@ -787,12 +788,13 @@ static void exit_notify(struct task_struct *tsk) | |||
787 | 788 | ||
788 | t = tsk->real_parent; | 789 | t = tsk->real_parent; |
789 | 790 | ||
790 | if ((process_group(t) != process_group(tsk)) && | 791 | pgrp = task_pgrp(tsk); |
791 | (process_session(t) == process_session(tsk)) && | 792 | if ((task_pgrp(t) != pgrp) && |
792 | will_become_orphaned_pgrp(process_group(tsk), tsk) && | 793 | (task_session(t) != task_session(tsk)) && |
793 | has_stopped_jobs(process_group(tsk))) { | 794 | will_become_orphaned_pgrp(pgrp, tsk) && |
794 | __kill_pg_info(SIGHUP, SEND_SIG_PRIV, process_group(tsk)); | 795 | has_stopped_jobs(pgrp)) { |
795 | __kill_pg_info(SIGCONT, SEND_SIG_PRIV, process_group(tsk)); | 796 | __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp); |
797 | __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp); | ||
796 | } | 798 | } |
797 | 799 | ||
798 | /* Let father know we died | 800 | /* Let father know we died |