• Michal Hocko's avatar
    mm, oom: do not enforce OOM killer for __GFP_NOFAIL automatically · 06ad276a
    Michal Hocko authored
    __alloc_pages_may_oom makes sure to skip the OOM killer depending on the
    allocation request.  This includes lowmem requests, costly high order
    requests and others.  For a long time __GFP_NOFAIL acted as an override
    for all those rules.  This is not documented and it can be quite
    surprising as well.  E.g.  GFP_NOFS requests are not invoking the OOM
    killer but GFP_NOFS|__GFP_NOFAIL does so if we try to convert some of
    the existing open coded loops around allocator to nofail request (and we
    have done that in the past) then such a change would have a non trivial
    side effect which is far from obvious.  Note that the primary motivation
    for skipping the OOM killer is to prevent from pre-mature invocation.
    
    The exception has been added by commit 82553a93 ("oom: invoke oom
    killer for __GFP_NOFAIL").  The changelog points out that the oom killer
    has to be invoked otherwise the request would be looping for ever.  But
    this argument is rather weak because the OOM killer doesn't really
    guarantee a forward progress for those exceptional cases:
    
    - it will hardly help to form costly order which in turn can result in
      the system panic because of no oom killable task in the end - I believe
      we certainly do not want to put the system down just because there is a
      nasty driver asking for order-9 page with GFP_NOFAIL not realizing all
      the consequences.  It is much better this request would loop for ever
      than the massive system disruption
    
    - lowmem is also highly unlikely to be freed during OOM killer
    
    - GFP_NOFS request could trigger while there is still a lot of memory
      pinned by filesystems.
    
    This patch simply removes the __GFP_NOFAIL special case in order to have a
    more clear semantic without surprising side effects.
    Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
    Reported-by: default avatarNils Holland <nholland@tisys.org>
    Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
    Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    06ad276a
page_alloc.c 205 KB