• Andrew Morton's avatar
    [PATCH] resurrect __GFP_HIGH · 371151c9
    Andrew Morton authored
    This patch reinstates __GFP_HIGH functionality.
    
    __GFP_HIGH means "able to dip into the emergency pools".  However,
    somewhere along the line this got broken.  __GFP_HIGH ceased to do
    anything.  Instead, !__GFP_WAIT is used to tell the page allocator to
    try harder.
    
    __GFP_HIGH makes sense.  The concepts of "unable to sleep" and "should
    try harder" are quite separate, and overloading !__GFP_WAIT to mean
    "should access emergency pools" seems wrong.
    
    This patch fixes a problem in mempool_alloc().  mempool_alloc() tries
    the first allocation with __GFP_WAIT cleared.  If that fails, it tries
    again with __GFP_WAIT enabled (if the caller can support __GFP_WAIT).
    So it is currently performing an atomic allocation first, even though
    the caller said that they're prepared to go in and call the page
    stealer.
    
    I thought this was a mempool bug, but Ingo said:
    
    > no, it's not GFP_ATOMIC. The important difference is __GFP_HIGH, which
    > triggers the intrusive highprio allocation mode. Otherwise gfp_nowait is
    > just a nonblocking allocation of the same type as the original gfp_mask.
    > ...
    > what i've added is a bit more subtle allocation method, with both
    > performance and balancing-correctness in mind:
    >
    > 1. allocate via gfp_mask, but nonblocking
    > 2. if failure => try to get from the pool if the pool is 'full enough'.
    > 3. if failure => allocate with gfp_mask [which might block]
    >
    > there is performance data that this method improves bounce-IO performance
    > significantly, because even under VM pressure (when gfp_mask would block)
    > we can still use up to 50% of the memory pool without blocking (and
    > without endangering deadlock-free allocation). Ie. the memory pool is also
    > a fast 'frontside cache' of memory elements.
    
    Ingo was assuming that __GFP_HIGH was still functional.  It isn't, and the
    mempool design wants it.
    371151c9
page_alloc.c 22.8 KB