• Andrew Morton's avatar
    [PATCH] account for slab reclaim in try_to_free_pages() · f31fd780
    Andrew Morton authored
    try_to_free_pages() currently fails to notice that it successfully freed slab
    pages via shrink_slab().  So it can keep looping and eventually call
    out_of_memory(), even though there's a lot of memory now free.
    
    And even if it doesn't do that, it can free too much memory.
    
    The patch changes try_to_free_pages() so that it will notice freed slab pages
    and will return when enough memory has been freed via shrink_slab().
    
    Many options were considered, but must of them were unacceptably inaccurate,
    intrusive or sleazy.  I ended up putting the accounting into a stack-local
    structure which is pointed to by current->reclaim_state.
    
    One reason for this is that we can cleanly resurrect the current->local_pages
    pool by putting it into struct reclaim_state.
    
    (current->local_pages was removed because the per-cpu page pools in the page
    allocator largely duplicate its function.  But it is still possible for
    interrupt-time allocations to steal just-freed pages, so we might want to put
    it back some time.)
    f31fd780
page_alloc.c 38 KB