• Andrew Morton's avatar
    [PATCH] deferred and batched addition of pages to the LRU · 44260240
    Andrew Morton authored
    The remaining source of page-at-a-time activity against
    pagemap_lru_lock is the anonymous pagefault path, which cannot be
    changed to operate against multiple pages at a time.
    
    But what we can do is to batch up just its adding of pages to the LRU,
    via buffering and deferral.
    
    This patch is based on work from Bill Irwin.
    
    The patch changes lru_cache_add to put the pages into a per-CPU
    pagevec.  They are added to the LRU 16-at-a-time.
    
    And in the page reclaim code, purge the local CPU's buffer before
    starting.  This is mainly to decrease the chances of pages staying off
    the LRU for very long periods: if the machine is under memory pressure,
    CPUs will spill their pages onto the LRU promptly.
    
    A consequence of this change is that we can have up to 15*num_cpus
    pages which are not on the LRU.  Which could have a slight effect on VM
    accuracy, but I find that doubtful.  If the system is under memory
    pressure the pages will be added to the LRU promptly, and these pages
    are the most-recently-touched ones - the VM isn't very interested in
    them anyway.
    
    This optimisation could be made SMP-specific, but I felt it best to
    turn it on for UP as well for consistency and better testing coverage.
    44260240
swap.c 5.61 KB