Skip to content

Commit

Permalink
mm/oom_kill: cleanup the "kill sharing same memory" loop
Browse files Browse the repository at this point in the history
Purely cosmetic, but the complex "if" condition looks annoying to me.
Especially because it is not consistent with OOM_SCORE_ADJ_MIN check
which adds another if/continue.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Kyle Walker <kwalker@redhat.com>
Cc: Stanislav Kozina <skozina@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
oleg-nesterov authored and torvalds committed Nov 6, 2015
1 parent 0c1b2d7 commit c319025
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions mm/oom_kill.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,18 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
* pending fatal signal.
*/
rcu_read_lock();
for_each_process(p)
if (p->mm == mm && !same_thread_group(p, victim) &&
!(p->flags & PF_KTHREAD)) {
if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
continue;
for_each_process(p) {
if (p->mm != mm)
continue;
if (same_thread_group(p, victim))
continue;
if (unlikely(p->flags & PF_KTHREAD))
continue;
if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
continue;

do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
}
do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true);
}
rcu_read_unlock();

mmdrop(mm);
Expand Down

0 comments on commit c319025

Please sign in to comment.