• NeilBrown's avatar
    mm: introduce memalloc_retry_wait() · 4034247a
    NeilBrown authored
    Various places in the kernel - largely in filesystems - respond to a
    memory allocation failure by looping around and re-trying.  Some of
    these cannot conveniently use __GFP_NOFAIL, for reasons such as:
    
     - a GFP_ATOMIC allocation, which __GFP_NOFAIL doesn't work on
     - a need to check for the process being signalled between failures
     - the possibility that other recovery actions could be performed
     - the allocation is quite deep in support code, and passing down an
       extra flag to say if __GFP_NOFAIL is wanted would be clumsy.
    
    Many of these currently use congestion_wait() which (in almost all
    cases) simply waits the given timeout - congestion isn't tracked for
    most devices.
    
    It isn't clear what the best delay is for loops, but it is clear that
    the various filesystems shouldn't be responsible for choosing a timeout.
    
    This patch introduces memalloc_retry_wait() with takes on that
    responsibility.  Code that wants to retry a memory allocation can call
    this function passing...
    4034247a
kmem.c 681 Bytes