• Mel Gorman's avatar
    mm/page_alloc: scale the number of pages that are batch freed · 3b12e7e9
    Mel Gorman authored
    When a task is freeing a large number of order-0 pages, it may acquire the
    zone->lock multiple times freeing pages in batches.  This may
    unnecessarily contend on the zone lock when freeing very large number of
    pages.  This patch adapts the size of the batch based on the recent
    pattern to scale the batch size for subsequent frees.
    
    As the machines I used were not large enough to test this are not large
    enough to illustrate a problem, a debugging patch shows patterns like the
    following (slightly editted for clarity)
    
    Baseline vanilla kernel
      time-unmap-14426   [...] free_pcppages_bulk: free   63 count  378 high  378
      time-unmap-14426   [...] free_pcppages_bulk: free   63 count  378 high  378
      time-unmap-14426   [...] free_pcppages_bulk: free   63 count  378 high  378
      time-unmap-14426   [...] free_pcppages_bulk: free   63 count  378 high  378
      time-unmap-14426   [...] free_pcppages_bulk: free   63 count  378 high  378
    
    With patches
      time-unmap-7724    [...] free_pcppages_bulk: free  126 count  814 high  814
      time-unmap-7724    [...] free_pcppages_bulk: free  252 count  814 high  814
      time-unmap-7724    [...] free_pcppages_bulk: free  504 count  814 high  814
      time-unmap-7724    [...] free_pcppages_bulk: free  751 count  814 high  814
      time-unmap-7724    [...] free_pcppages_bulk: free  751 count  814 high  814
    
    Link: https://lkml.kernel.org/r/20210525080119.5455-5-mgorman@techsingularity.netSigned-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
    Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
    Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
    Cc: Hillf Danton <hdanton@sina.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3b12e7e9
page_alloc.c 259 KB