Commit 8c5cd6f3 authored by KOSAKI Motohiro's avatar KOSAKI Motohiro Committed by Linus Torvalds

oom: oom_kill doesn't kill vfork parent (or child)

Current oom_kill doesn't only kill the victim process, but also kill all
thas shread the same mm.  it mean vfork parent will be killed.

This is definitely incorrect.  another process have another oom_adj.  we
shouldn't ignore their oom_adj (it might have OOM_DISABLE).

following caller hit the minefield.

===============================
        switch (constraint) {
        case CONSTRAINT_MEMORY_POLICY:
                oom_kill_process(current, gfp_mask, order, 0, NULL,
                                "No available memory (MPOL_BIND)");
                break;

Note: force_sig(SIGKILL) send SIGKILL to all thread in the process.
We don't need to care multi thread in here.
Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 495789a5
...@@ -373,11 +373,6 @@ static void __oom_kill_task(struct task_struct *p, int verbose) ...@@ -373,11 +373,6 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
static int oom_kill_task(struct task_struct *p) static int oom_kill_task(struct task_struct *p)
{ {
struct mm_struct *mm;
struct task_struct *g, *q;
mm = p->mm;
/* WARNING: mm may not be dereferenced since we did not obtain its /* WARNING: mm may not be dereferenced since we did not obtain its
* value from get_task_mm(p). This is OK since all we need to do is * value from get_task_mm(p). This is OK since all we need to do is
* compare mm to q->mm below. * compare mm to q->mm below.
...@@ -386,21 +381,11 @@ static int oom_kill_task(struct task_struct *p) ...@@ -386,21 +381,11 @@ static int oom_kill_task(struct task_struct *p)
* change to NULL at any time since we do not hold task_lock(p). * change to NULL at any time since we do not hold task_lock(p).
* However, this is of no concern to us. * However, this is of no concern to us.
*/ */
if (!mm || p->signal->oom_adj == OOM_DISABLE) if (!p->mm || p->signal->oom_adj == OOM_DISABLE)
return 1; return 1;
__oom_kill_task(p, 1); __oom_kill_task(p, 1);
/*
* kill all processes that share the ->mm (i.e. all threads),
* but are in a different thread group. Don't let them have access
* to memory reserves though, otherwise we might deplete all memory.
*/
do_each_thread(g, q) {
if (q->mm == mm && !same_thread_group(q, p))
force_sig(SIGKILL, q);
} while_each_thread(g, q);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment