Subject: + oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch added to -mm tree To: ming.liu@xxxxxxxxxxxxx,rientjes@xxxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Tue, 24 Sep 2013 16:48:23 -0700 The patch titled Subject: oom: avoid killing init if it assumed the oom killed thread's mm has been added to the -mm tree. Its filename is oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ming Liu <ming.liu@xxxxxxxxxxxxx> 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. Signed-off-by: Ming Liu <ming.liu@xxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/oom_kill.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff -puN mm/oom_kill.c~oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm mm/oom_kill.c --- a/mm/oom_kill.c~oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm +++ a/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 ming.liu@xxxxxxxxxxxxx are oom-avoid-killing-init-if-it-assumed-the-oom-killed-threads-mm.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html