• David Rientjes's avatar
    oom, memcg: fix exclusion of memcg threads after they have detached their mm · de077d22
    David Rientjes authored
    The oom killer relies on logic that identifies threads that have already
    been oom killed when scanning the tasklist and, if found, deferring
    until such threads have exited.  This is done by checking for any
    candidate threads that have the TIF_MEMDIE bit set.
    
    For memcg ooms, candidate threads are first found by calling
    task_in_mem_cgroup() since the oom killer should not defer if there's an
    oom killed thread in another memcg.
    
    Unfortunately, task_in_mem_cgroup() excludes threads if they have
    detached their mm in the process of exiting so TIF_MEMDIE is never
    detected for such conditions.  This is different for global, mempolicy,
    and cpuset oom conditions where a detached mm is only excluded after
    checking for TIF_MEMDIE and deferring, if necessary, in
    select_bad_process().
    
    The fix is to return true if a task has a detached mm but is still in
    the memcg or its hierarchy that is currently oom.  This will allow the
    oom killer to appropriately defer rather than kill unnecessarily or, in
    the worst case, panic the machine if nothing else is available to kill.
    Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
    Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Balbir Singh <bsingharora@gmail.com>
    Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    de077d22
memcontrol.c 146 KB