aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2015-11-06 19:32:34 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-06 20:50:42 -0500
commitd61ba58953fcf708c850bfd90b2858f2ddfbc34c (patch)
tree2f40955b30bd9147934ef5b1eb8bd0498cfb41c8
parent5fa534c987784c4811757a34c425aff3ce3b5037 (diff)
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: Oleg 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/coredump.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/fs/coredump.c b/fs/coredump.c
index c66bb0572265..1777331eee76 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -290,15 +290,14 @@ static int zap_process(struct task_struct *start, int exit_code, int flags)
290 start->signal->group_exit_code = exit_code; 290 start->signal->group_exit_code = exit_code;
291 start->signal->group_stop_count = 0; 291 start->signal->group_stop_count = 0;
292 292
293 t = start; 293 for_each_thread(start, t) {
294 do {
295 task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK); 294 task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
296 if (t != current && t->mm) { 295 if (t != current && t->mm) {
297 sigaddset(&t->pending.signal, SIGKILL); 296 sigaddset(&t->pending.signal, SIGKILL);
298 signal_wake_up(t, 1); 297 signal_wake_up(t, 1);
299 nr++; 298 nr++;
300 } 299 }
301 } while_each_thread(start, t); 300 }
302 301
303 return nr; 302 return nr;
304} 303}
@@ -360,18 +359,18 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm,
360 continue; 359 continue;
361 if (g->flags & PF_KTHREAD) 360 if (g->flags & PF_KTHREAD)
362 continue; 361 continue;
363 p = g; 362
364 do { 363 for_each_thread(g, p) {
365 if (p->mm) { 364 if (unlikely(!p->mm))
366 if (unlikely(p->mm == mm)) { 365 continue;
367 lock_task_sighand(p, &flags); 366 if (unlikely(p->mm == mm)) {
368 nr += zap_process(p, exit_code, 367 lock_task_sighand(p, &flags);
369 SIGNAL_GROUP_EXIT); 368 nr += zap_process(p, exit_code,
370 unlock_task_sighand(p, &flags); 369 SIGNAL_GROUP_EXIT);
371 } 370 unlock_task_sighand(p, &flags);
372 break;
373 } 371 }
374 } while_each_thread(g, p); 372 break;
373 }
375 } 374 }
376 rcu_read_unlock(); 375 rcu_read_unlock();
377done: 376done: