mm/oom_kill: cleanup the "kill sharing same memory" loop
[firefly-linux-kernel-4.4.55.git] / mm / oom_kill.c
index c837d06dce5a447787b9965f5bf2103aaab98e64..2b6e8809d7a85211149aec0d160ee36fbc414a60 100644 (file)
@@ -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);