• H
    [PATCH] overcommit: add calculate_totalreserve_pages() · cb45b0e9
    Hideo AOKI 提交于
    These patches are an enhancement of OVERCOMMIT_GUESS algorithm in
    __vm_enough_memory().
    
    - why the kernel needed patching
    
      When the kernel can't allocate anonymous pages in practice, currnet
      OVERCOMMIT_GUESS could return success. This implementation might be
      the cause of oom kill in memory pressure situation.
    
      If the Linux runs with page reservation features like
      /proc/sys/vm/lowmem_reserve_ratio and without swap region, I think
      the oom kill occurs easily.
    
    - the overall design approach in the patch
    
      When the OVERCOMMET_GUESS algorithm calculates number of free pages,
      the reserved free pages are regarded as non-free pages.
    
      This change helps to avoid the pitfall that the number of free pages
      become less than the number which the kernel tries to keep free.
    
    - testing results
    
      I tested the patches using my test kernel module.
    
      If the patches aren't applied to the kernel, __vm_enough_memory()
      returns success in the situation but autual page allocation is
      failed.
    
      On the other hand, if the patches are applied to the kernel, memory
      allocation failure is avoided since __vm_enough_memory() returns
      failure in the situation.
    
      I checked that on i386 SMP 16GB memory machine. I haven't tested on
      nommu environment currently.
    
    This patch adds totalreserve_pages for __vm_enough_memory().
    
    Calculate_totalreserve_pages() checks maximum lowmem_reserve pages and
    pages_high in each zone. Finally, the function stores the sum of each
    zone to totalreserve_pages.
    
    The totalreserve_pages is calculated when the VM is initilized.
    And the variable is updated when /proc/sys/vm/lowmem_reserve_raito
    or /proc/sys/vm/min_free_kbytes are changed.
    Signed-off-by: NHideo Aoki <haoki@redhat.com>
    Signed-off-by: NAndrew Morton <akpm@osdl.org>
    Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
    cb45b0e9
page_alloc.c 69.7 KB