Skip to contentSkip to conversation

oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch removed from -mm tree

to-be-updated [email protected] 1 participant 1 message Sep 25, 2013

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: [to-be-updated] oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch removed from -mm tree
To: [email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 25 Sep 2013 12:47:17 -0700

The patch titled
Subject: oom: avoid killing init if it assumed the oom killed thread's mm
has been removed from the -mm tree. Its filename was
oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: Ming Liu <[email protected]>
Subject: oom: avoid killing init if it assumed the oom killed thread's mm

After selecting a task to kill, the oom killer iterates all processes and kills all other user threads that share the same mm_struct in different thread groups.

But in some extreme cases, the selected task happens to be a vfork child of init process sharing the same mm_struct with it, which causes kernel panic on init getting killed. This panic is observed in a busybox shell that busybox itself is init, when a kthread keeps consuming memory.

---

 mm/oom_kill.c |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/oom_kill.c renamed from mm/oom_kill.c~oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm +8 -8
diff -puN mm/oom_kill.c~oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm mm/oom_kill.c
@@ -479,17 +479,17 @@ void oom_kill_process(struct task_struct
 	task_unlock(victim);
 
 	/*
-	 * Kill all user processes sharing victim->mm in other thread groups, if
-	 * any.  They don't get access to memory reserves, though, to avoid
-	 * depletion of all memory.  This prevents mm->mmap_sem livelock when an
-	 * oom killed thread cannot exit because it requires the semaphore and
-	 * its contended by another thread trying to allocate memory itself.
-	 * That thread will now get access to memory reserves since it has a
-	 * pending fatal signal.
+	 * Kill all user processes except init sharing victim->mm in other
+	 * thread groups, if any.  They don't get access to memory reserves,
+	 * though, to avoid depletion of all memory.  This prevents mm->mmap_sem
+	 * livelock when an oom killed thread cannot exit because it requires
+	 * the semaphore and its contended by another thread trying to allocate
+	 * memory itself. That thread will now get access to memory reserves
+	 * since it has a pending fatal signal.
 	 */
 	for_each_process(p)
 		if (p->mm == mm && !same_thread_group(p, victim) &&
-		    !(p->flags & PF_KTHREAD)) {
+		    !(p->flags & PF_KTHREAD) && !is_global_init(p)) {
 			if (p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN)
 				continue;
 

_

Patches currently in -mm which might be from [email protected] are