• Joonsoo Kim's avatar
    mm/compaction: stop the isolation when we isolate enough freepage · 932ff6bb
    Joonsoo Kim authored
    Currently, freepage isolation in one pageblock doesn't consider how many
    freepages we isolate. When I traced flow of compaction, compaction
    sometimes isolates more than 256 freepages to migrate just 32 pages.
    
    In this patch, freepage isolation is stopped at the point that we
    have more isolated freepage than isolated page for migration. This
    results in slowing down free page scanner and make compaction success
    rate higher.
    
    stress-highalloc test in mmtests with non movable order 7 allocation shows
    increase of compaction success rate.
    
    Compaction success rate (Compaction success * 100 / Compaction stalls, %)
    27.13 : 31.82
    
    pfn where both scanners meets on compaction complete
    (separate test due to enormous tracepoint buffer)
    (zone_start=4096, zone_end=1048576)
    586034 : 654378
    
    In fact, I didn't fully understand why this patch results in such good
    result. There was a guess that not used freepages are released to pcp list
    and on next compaction trial we won't isolate them again so compaction
    success rate would decrease. To prevent this effect, I tested with adding
    pcp drain code on release_freepages(), but, it has no good effect.
    
    Anyway, this patch reduces waste time to isolate unneeded freepages so
    seems reasonable.
    
    Vlastimil said:
    
    : I briefly tried it on top of the pivot-changing series and with order-9
    : allocations it reduced free page scanned counter by almost 10%.  No effect
    : on success rates (maybe because pivot changing already took care of the
    : scanners meeting problem) but the scanning reduction is good on its own.
    :
    : It also explains why e14c720e ("mm, compaction: remember position
    : within pageblock in free pages scanner") had less than expected
    : improvements.  It would only actually stop within pageblock in case of
    : async compaction detecting contention.  I guess that's also why the
    : infinite loop problem fixed by 1d5bfe1f affected so relatively few
    : people.
    Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
    Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
    Tested-by: default avatarVlastimil Babka <vbabka@suse.cz>
    Reviewed-by: default avatarZhang Yanfei <zhangyanfei@cn.fujitsu.com>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Rik van Riel <riel@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    932ff6bb
compaction.c 46.5 KB