Loading mm/oom_kill.c +36 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,28 @@ static atomic64_t ulmk_kill_jiffies = ATOMIC64_INIT(INITIAL_JIFFIES); static unsigned long psi_emergency_jiffies = INITIAL_JIFFIES; static DEFINE_MUTEX(ulmk_retry_lock); static bool ulmk_kill_possible(void) { struct task_struct *tsk; bool ret = false; rcu_read_lock(); for_each_process(tsk) { if (tsk->flags & PF_KTHREAD) continue; task_lock(tsk); if (tsk->signal->oom_score_adj >= 0) { ret = true; task_unlock(tsk); break; } task_unlock(tsk); } rcu_read_unlock(); return ret; } /* * psi_emergency_jiffies represents the last ULMK emergency event. Loading Loading @@ -107,6 +129,20 @@ bool should_ulmk_retry(void) goto out; } /* * We reached here means no kill have had happened since the last * emergency trigger for 2*HZ window. We can't derive the status * of the low memory killer here. So, before falling back to OOM, * check for any +ve adj tasks left in the system in repeat for * next 20*HZ. Indirectly the below logic also giving 20HZ window * for the first emergency trigger. */ if (time_after(psi_emergency_jiffies + 20 * HZ, now) && ulmk_kill_possible()) { ret = true; goto out; } out: mutex_unlock(&ulmk_retry_lock); return ret; Loading Loading
mm/oom_kill.c +36 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,28 @@ static atomic64_t ulmk_kill_jiffies = ATOMIC64_INIT(INITIAL_JIFFIES); static unsigned long psi_emergency_jiffies = INITIAL_JIFFIES; static DEFINE_MUTEX(ulmk_retry_lock); static bool ulmk_kill_possible(void) { struct task_struct *tsk; bool ret = false; rcu_read_lock(); for_each_process(tsk) { if (tsk->flags & PF_KTHREAD) continue; task_lock(tsk); if (tsk->signal->oom_score_adj >= 0) { ret = true; task_unlock(tsk); break; } task_unlock(tsk); } rcu_read_unlock(); return ret; } /* * psi_emergency_jiffies represents the last ULMK emergency event. Loading Loading @@ -107,6 +129,20 @@ bool should_ulmk_retry(void) goto out; } /* * We reached here means no kill have had happened since the last * emergency trigger for 2*HZ window. We can't derive the status * of the low memory killer here. So, before falling back to OOM, * check for any +ve adj tasks left in the system in repeat for * next 20*HZ. Indirectly the below logic also giving 20HZ window * for the first emergency trigger. */ if (time_after(psi_emergency_jiffies + 20 * HZ, now) && ulmk_kill_possible()) { ret = true; goto out; } out: mutex_unlock(&ulmk_retry_lock); return ret; Loading