summaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-12-10 15:45:30 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 17:41:10 -0800
commit2831096e21503897ee474c23131c3feb8db0ffb1 (patch)
treece85582dca41140cf7bea54d4051aa50fcc4fe13 /kernel/exit.c
parent57a059187d5ba5592e36c6f23d046bc37616f346 (diff)
downloadlinux-stable-2831096e21503897ee474c23131c3feb8db0ffb1.tar.gz
linux-stable-2831096e21503897ee474c23131c3feb8db0ffb1.tar.bz2
linux-stable-2831096e21503897ee474c23131c3feb8db0ffb1.zip
exit: reparent: cleanup the usage of reparent_leader()
1. Now that reparent_leader() doesn't abuse ->sibling we can shift list_move_tail() from reparent_leader() to forget_original_parent() and turn it into a single list_splice_tail_init(). This also makes BUG_ON(!list_empty()) and list_for_each_entry_safe() unnecessary. 2. This also allows to shift the same_thread_group() check, it looks a bit more clear in the caller. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Aaron Tomlin <atomlin@redhat.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com>, Cc: Sterling Alexander <stalexan@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Roland McGrath <roland@hack.frob.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 464971e6923e..772e9175735c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -529,15 +529,7 @@ static struct task_struct *find_new_reaper(struct task_struct *father)
static void reparent_leader(struct task_struct *father, struct task_struct *p,
struct list_head *dead)
{
- list_move_tail(&p->sibling, &p->real_parent->children);
-
- if (p->exit_state == EXIT_DEAD)
- return;
- /*
- * If this is a threaded reparent there is no need to
- * notify anyone anything has happened.
- */
- if (same_thread_group(p->real_parent, father))
+ if (unlikely(p->exit_state == EXIT_DEAD))
return;
/* We don't want people slaying init. */
@@ -568,7 +560,7 @@ static void forget_original_parent(struct task_struct *father)
exit_ptrace(father);
reaper = find_new_reaper(father);
- list_for_each_entry_safe(p, n, &father->children, sibling) {
+ list_for_each_entry(p, &father->children, sibling) {
for_each_thread(p, t) {
t->real_parent = reaper;
BUG_ON((!t->ptrace) != (t->parent == father));
@@ -578,12 +570,16 @@ static void forget_original_parent(struct task_struct *father)
group_send_sig_info(t->pdeath_signal,
SEND_SIG_NOINFO, t);
}
- reparent_leader(father, p, &dead_children);
+ /*
+ * If this is a threaded reparent there is no need to
+ * notify anyone anything has happened.
+ */
+ if (!same_thread_group(reaper, father))
+ reparent_leader(father, p, &dead_children);
}
+ list_splice_tail_init(&father->children, &reaper->children);
write_unlock_irq(&tasklist_lock);
- BUG_ON(!list_empty(&father->children));
-
list_for_each_entry_safe(p, n, &dead_children, ptrace_entry) {
list_del_init(&p->ptrace_entry);
release_task(p);