• Andrew Morton's avatar
    [PATCH] reduced and tunable swappiness · 8f7a1404
    Andrew Morton authored
    /proc/sys/vm/swappiness controls the VM's tendency to unmap pages and to
    swap things out.
    
    100 -> basically current 2.5 behaviour
    0 -> not very swappy at all
    
    The mechanism which is used to control swappiness is: to be reluctant
    to bring mapped pages onto the inactive list.  Prefer to reclaim
    pagecache instead.
    
    The control for that mechanism is as follows:
    
    - If there is a large amount of mapped memory in the machine, we
      prefer to bring mapped pages onto the inactive list.
    
    - If page reclaim is under distress (more scanning is happening) then
      prefer to bring mapped pages onto the inactive list.  This is
      basically the 2.4 algorithm, really.
    
    - If the /proc/sys/vm/swappiness control is high then prefer to bring
      mapped pages onto the inactive list.
    
    The implementation is simple: calculate the above three things as
    percentages and add them up.  If that's over 100% then start reclaiming
    mapped pages.
    
    The `proportion of mapped memory' is downgraded so that we don't swap
    just because a lot of memory is mapped into pagetables - we still need
    some VM distress before starting to swap that memory out.
    
    For a while I was adding a little bias so that we prefer to unmap
    file-backed memory before swapping out anon memory.  Because usually
    file backed memory can be evicted and reestablished with one I/O, not
    two.  It was unmapping executable text too easily, so here I just treat
    them equally.
    8f7a1404
vmscan.c 25 KB