• David Rientjes's avatar
    oom: avoid deferring oom killer if exiting task is being traced · edd45544
    David Rientjes authored
    The oom killer naturally defers killing anything if it finds an eligible
    task that is already exiting and has yet to detach its ->mm.  This avoids
    unnecessarily killing tasks when one is already in the exit path and may
    free enough memory that the oom killer is no longer needed.  This is
    detected by PF_EXITING since threads that have already detached its ->mm
    are no longer considered at all.
    
    The problem with always deferring when a thread is PF_EXITING, however, is
    that it may never actually exit when being traced, specifically if another
    task is tracing it with PTRACE_O_TRACEEXIT.  The oom killer does not want
    to defer in this case since there is no guarantee that thread will ever
    exit without intervention.
    
    This patch will now only defer the oom killer when a thread is PF_EXITING
    and no ptracer has stopped its progress in the exit path.  It also ensures
    that a child is sacrificed for the chosen parent only if it has a
    different ->mm as the comment implies: this ensures that the thread group
    leader is always targeted appropriately.
    Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
    Reported-by: default avatarOleg Nesterov <oleg@redhat.com>
    Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Andrey Vagin <avagin@openvz.org>
    Cc: <stable@kernel.org>		[2.6.38.x]
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    edd45544
oom_kill.c 21.4 KB