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

Commit 0da19467 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm, oom: remove oom_lock from oom_reaper"

parents ac05034d 0ceec5e7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -3138,9 +3138,7 @@ void exit_mmap(struct mm_struct *mm)
		 * which clears VM_LOCKED, otherwise the oom reaper cannot
		 * reliably test it.
		 */
		mutex_lock(&oom_lock);
		__oom_reap_task_mm(mm);
		mutex_unlock(&oom_lock);

		set_bit(MMF_OOM_SKIP, &mm->flags);
		down_write(&mm->mmap_sem);
+4 −25
Original line number Diff line number Diff line
@@ -504,28 +504,9 @@ void __oom_reap_task_mm(struct mm_struct *mm)

static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
{
	bool ret = true;

	/*
	 * We have to make sure to not race with the victim exit path
	 * and cause premature new oom victim selection:
	 * oom_reap_task_mm		exit_mm
	 *   mmget_not_zero
	 *				  mmput
	 *				    atomic_dec_and_test
	 *				  exit_oom_victim
	 *				[...]
	 *				out_of_memory
	 *				  select_bad_process
	 *				    # no TIF_MEMDIE task selects new victim
	 *  unmap_page_range # frees some memory
	 */
	mutex_lock(&oom_lock);

	if (!down_read_trylock(&mm->mmap_sem)) {
		ret = false;
		trace_skip_task_reaping(tsk->pid);
		goto unlock_oom;
		return false;
	}

	/*
@@ -540,7 +521,7 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
	if (mm_has_notifiers(mm)) {
		up_read(&mm->mmap_sem);
		schedule_timeout_idle(HZ);
		goto unlock_oom;
		return true;
	}

	/*
@@ -552,7 +533,7 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
	if (test_bit(MMF_OOM_SKIP, &mm->flags)) {
		up_read(&mm->mmap_sem);
		trace_skip_task_reaping(tsk->pid);
		goto unlock_oom;
		return true;
	}

	trace_start_task_reaping(tsk->pid);
@@ -567,9 +548,7 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
	up_read(&mm->mmap_sem);

	trace_finish_task_reaping(tsk->pid);
unlock_oom:
	mutex_unlock(&oom_lock);
	return ret;
	return true;
}

#define MAX_OOM_REAP_RETRIES 10