Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 897b9898 authored by Prakash Gupta's avatar Prakash Gupta
Browse files

lowmemorykiller: avoid selecting task reaped by oom_reaper



With oom_reaper enabled for lowmemorykiller, even when the oom_reaper reaps
the task, the task struct will have LMK_WAITING flag set.  As a side
effect, during lowmem_deathpending_timeout period, lowmemorykiller will not
select any task while any task has LMK_WAITING flag set.

Skip tasks from lmk selection if they are reaped by oom_reaper.

Change-Id: I7edb02135df7e54d9364b971caf25ab6ace9a027
Signed-off-by: default avatarPrakash Gupta <guptap@codeaurora.org>
parent a8bac554
Loading
Loading
Loading
Loading
+28 −9
Original line number Diff line number Diff line
@@ -510,17 +510,36 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
		if (test_task_flag(tsk, TIF_MM_RELEASED))
			continue;

		if (time_before_eq(jiffies, lowmem_deathpending_timeout)) {
			if (test_task_lmk_waiting(tsk)) {
		if (oom_reaper) {
			p = find_lock_task_mm(tsk);
			if (!p)
				continue;

			if (test_bit(MMF_OOM_VICTIM, &p->mm->flags)) {
				if (test_bit(MMF_OOM_SKIP, &p->mm->flags)) {
					task_unlock(p);
					continue;
				} else if (time_before_eq(jiffies,
						lowmem_deathpending_timeout)) {
					task_unlock(p);
					rcu_read_unlock();
					mutex_unlock(&scan_mutex);
					return 0;
				}
			}
		} else {
			if (time_before_eq(jiffies,
					   lowmem_deathpending_timeout))
				if (test_task_lmk_waiting(tsk)) {
					rcu_read_unlock();
					mutex_unlock(&scan_mutex);
					return 0;
				}

			p = find_lock_task_mm(tsk);
			if (!p)
				continue;
		}

		oom_score_adj = p->signal->oom_score_adj;
		if (oom_score_adj < min_score_adj) {