Commit 8c5cd6f3a1721085652da204d454af4f8b92eda2

Authored by KOSAKI Motohiro
Committed by Linus Torvalds
1 parent 495789a51a

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: KOSAKI 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 1 additions and 16 deletions Side-by-side Diff

... ... @@ -373,11 +373,6 @@
373 373  
374 374 static int oom_kill_task(struct task_struct *p)
375 375 {
376   - struct mm_struct *mm;
377   - struct task_struct *g, *q;
378   -
379   - mm = p->mm;
380   -
381 376 /* WARNING: mm may not be dereferenced since we did not obtain its
382 377 * value from get_task_mm(p). This is OK since all we need to do is
383 378 * compare mm to q->mm below.
384 379  
... ... @@ -386,20 +381,10 @@
386 381 * change to NULL at any time since we do not hold task_lock(p).
387 382 * However, this is of no concern to us.
388 383 */
389   - if (!mm || p->signal->oom_adj == OOM_DISABLE)
  384 + if (!p->mm || p->signal->oom_adj == OOM_DISABLE)
390 385 return 1;
391 386  
392 387 __oom_kill_task(p, 1);
393   -
394   - /*
395   - * kill all processes that share the ->mm (i.e. all threads),
396   - * but are in a different thread group. Don't let them have access
397   - * to memory reserves though, otherwise we might deplete all memory.
398   - */
399   - do_each_thread(g, q) {
400   - if (q->mm == mm && !same_thread_group(q, p))
401   - force_sig(SIGKILL, q);
402   - } while_each_thread(g, q);
403 388  
404 389 return 0;
405 390 }