Commit d61ba589 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

coredump: change zap_threads() and zap_process() to use for_each_thread()

Change zap_threads() paths to use for_each_thread() rather than
while_each_thread().

While at it, change zap_threads() to avoid the nested if's to make the
code more readable and lessen the indentation.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Kyle Walker <kwalker@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Stanislav Kozina <skozina@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5fa534c9
...@@ -290,15 +290,14 @@ static int zap_process(struct task_struct *start, int exit_code, int flags) ...@@ -290,15 +290,14 @@ static int zap_process(struct task_struct *start, int exit_code, int flags)
start->signal->group_exit_code = exit_code; start->signal->group_exit_code = exit_code;
start->signal->group_stop_count = 0; start->signal->group_stop_count = 0;
t = start; for_each_thread(start, t) {
do {
task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK); task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
if (t != current && t->mm) { if (t != current && t->mm) {
sigaddset(&t->pending.signal, SIGKILL); sigaddset(&t->pending.signal, SIGKILL);
signal_wake_up(t, 1); signal_wake_up(t, 1);
nr++; nr++;
} }
} while_each_thread(start, t); }
return nr; return nr;
} }
...@@ -360,18 +359,18 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm, ...@@ -360,18 +359,18 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
continue; continue;
if (g->flags & PF_KTHREAD) if (g->flags & PF_KTHREAD)
continue; continue;
p = g;
do { for_each_thread(g, p) {
if (p->mm) { if (unlikely(!p->mm))
if (unlikely(p->mm == mm)) { continue;
lock_task_sighand(p, &flags); if (unlikely(p->mm == mm)) {
nr += zap_process(p, exit_code, lock_task_sighand(p, &flags);
SIGNAL_GROUP_EXIT); nr += zap_process(p, exit_code,
unlock_task_sighand(p, &flags); SIGNAL_GROUP_EXIT);
} unlock_task_sighand(p, &flags);
break;
} }
} while_each_thread(g, p); break;
}
} }
rcu_read_unlock(); rcu_read_unlock();
done: done:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment