Messages in this thread Patch in this message | | | Date | Tue, 29 Sep 2015 17:55:05 +0200 | From | Oleg Nesterov <> | Subject | [PATCH 2/2] coredump: change zap_threads() and zap_process() to use |
| |
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> --- fs/coredump.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c index 4fed8d0..b3c153c 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -292,15 +292,14 @@ static int zap_process(struct task_struct *start, int exit_code, int flags) start->signal->group_exit_code = exit_code; start->signal->group_stop_count = 0; - t = start; - do { + for_each_thread(start, t) { task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK); if (t != current && t->mm) { sigaddset(&t->pending.signal, SIGKILL); signal_wake_up(t, 1); nr++; } - } while_each_thread(start, t); + } return nr; } @@ -362,18 +361,18 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm, continue; if (g->flags & PF_KTHREAD) continue; - p = g; - do { - if (p->mm) { - if (unlikely(p->mm == mm)) { - lock_task_sighand(p, &flags); - nr += zap_process(p, exit_code, - SIGNAL_GROUP_EXIT); - unlock_task_sighand(p, &flags); - } - break; + + for_each_thread(g, p) { + if (unlikely(!p->mm)) + continue; + if (unlikely(p->mm == mm)) { + lock_task_sighand(p, &flags); + nr += zap_process(p, exit_code, + SIGNAL_GROUP_EXIT); + unlock_task_sighand(p, &flags); } - } while_each_thread(g, p); + break; + } } rcu_read_unlock(); done: -- 2.4.3
| |