• J
    mm/compaction: enhance compaction finish condition · 2149cdae
    Joonsoo Kim 提交于
    Compaction has anti fragmentation algorithm.  It is that freepage should
    be more than pageblock order to finish the compaction if we don't find any
    freepage in requested migratetype buddy list.  This is for mitigating
    fragmentation, but, there is a lack of migratetype consideration and it is
    too excessive compared to page allocator's anti fragmentation algorithm.
    
    Not considering migratetype would cause premature finish of compaction.
    For example, if allocation request is for unmovable migratetype, freepage
    with CMA migratetype doesn't help that allocation and compaction should
    not be stopped.  But, current logic regards this situation as compaction
    is no longer needed, so finish the compaction.
    
    Secondly, condition is too excessive compared to page allocator's logic.
    We can steal freepage from other migratetype and change pageblock
    migratetype on more relaxed conditions in page allocator.  This is
    designed to prevent fragmentation and we can use it here.  Imposing hard
    constraint only to the compaction doesn't help much in this case since
    page allocator would cause fragmentation again.
    
    To solve these problems, this patch borrows anti fragmentation logic from
    page allocator.  It will reduce premature compaction finish in some cases
    and reduce excessive compaction work.
    
    stress-highalloc test in mmtests with non movable order 7 allocation shows
    considerable increase of compaction success rate.
    
    Compaction success rate (Compaction success * 100 / Compaction stalls, %)
    31.82 : 42.20
    
    I tested it on non-reboot 5 runs stress-highalloc benchmark and found that
    there is no more degradation on allocation success rate than before.  That
    roughly means that this patch doesn't result in more fragmentations.
    
    Vlastimil suggests additional idea that we only test for fallbacks when
    migration scanner has scanned a whole pageblock.  It looked good for
    fragmentation because chance of stealing increase due to making more free
    pages in certain pageblock.  So, I tested it, but, it results in decreased
    compaction success rate, roughly 38.00.  I guess the reason that if system
    is low memory condition, watermark check could be failed due to not enough
    order 0 free page and so, sometimes, we can't reach a fallback check
    although migrate_pfn is aligned to pageblock_nr_pages.  I can insert code
    to cope with this situation but it makes code more complicated so I don't
    include his idea at this patch.
    
    [akpm@linux-foundation.org: fix CONFIG_CMA=n build]
    Signed-off-by: NJoonsoo Kim <iamjoonsoo.kim@lge.com>
    Acked-by: NVlastimil Babka <vbabka@suse.cz>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    2149cdae
page_alloc.c 183.7 KB