Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3750ef97 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

exit: reparent: s/while_each_thread/for_each_thread/ in find_new_reaper()



Change find_new_reaper() to use for_each_thread() instead of deprecated
while_each_thread().  We do not bother to check "thread != father" in the
1st loop, we can rely on PF_EXITING check.

Note: this means the minor behavioural change: for_each_thread() starts
from the group leader.  But this should be fine, nobody should make any
assumption about do_wait(__WNOTHREAD) when it comes to reparented tasks.
And this can avoid the pointless reparenting to a short-living thread
While zombie leaders are not that common.

Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Aaron Tomlin <atomlin@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Kay Sievers <kay@vrfy.org>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Sterling Alexander <stalexan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7d24e2df
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -473,8 +473,7 @@ static struct task_struct *find_new_reaper(struct task_struct *father)
	struct pid_namespace *pid_ns = task_active_pid_ns(father);
	struct pid_namespace *pid_ns = task_active_pid_ns(father);
	struct task_struct *thread;
	struct task_struct *thread;


	thread = father;
	for_each_thread(father, thread) {
	while_each_thread(father, thread) {
		if (thread->flags & PF_EXITING)
		if (thread->flags & PF_EXITING)
			continue;
			continue;
		if (unlikely(pid_ns->child_reaper == father))
		if (unlikely(pid_ns->child_reaper == father))
@@ -511,11 +510,10 @@ static struct task_struct *find_new_reaper(struct task_struct *father)
				break;
				break;
			if (!reaper->signal->is_child_subreaper)
			if (!reaper->signal->is_child_subreaper)
				continue;
				continue;
			thread = reaper;
			for_each_thread(reaper, thread) {
			do {
				if (!(thread->flags & PF_EXITING))
				if (!(thread->flags & PF_EXITING))
					return thread;
					return thread;
			} while_each_thread(reaper, thread);
			}
		}
		}
	}
	}