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

Commit 184101bf authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds
Browse files

oom: prevent livelock when oom_kill_allocating_task is set



When /proc/sys/vm/oom_kill_allocating_task is set for large systems that
want to avoid the lengthy tasklist scan, it's possible to livelock if
current is ineligible for oom kill.  This normally happens when it is set
to OOM_DISABLE, but is also possible if any threads are sharing the same
->mm with a different tgid.

So change __out_of_memory() to fall back to the full task-list scan if it
was unable to kill `current'.

Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent df3935ff
Loading
Loading
Loading
Loading
+21 −23
Original line number Diff line number Diff line
@@ -514,14 +514,13 @@ void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask)
 */
static void __out_of_memory(gfp_t gfp_mask, int order)
{
	if (sysctl_oom_kill_allocating_task) {
		oom_kill_process(current, gfp_mask, order, 0, NULL,
				"Out of memory (oom_kill_allocating_task)");

	} else {
		unsigned long points;
	struct task_struct *p;
	unsigned long points;

	if (sysctl_oom_kill_allocating_task)
		if (!oom_kill_process(current, gfp_mask, order, 0, NULL,
				"Out of memory (oom_kill_allocating_task)"))
			return;
retry:
	/*
	 * Rambo mode: Shoot down a process and hope it solves whatever
@@ -542,7 +541,6 @@ static void __out_of_memory(gfp_t gfp_mask, int order)
			     "Out of memory"))
		goto retry;
}
}

/*
 * pagefault handler calls into here because it is out of memory but