[Devel] [PATCH RHEL7 COMMIT] ms/mm/compaction: do not call suitable_migration_target() on every page

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jan 31 18:21:54 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-693.11.6.vz7.42.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.6.vz7.42.4
------>
commit 4ce80d5f804990b5ee7174f8a40f7ed43cde5c9d
Author: Joonsoo Kim <iamjoonsoo.kim at lge.com>
Date:   Wed Jan 31 18:21:54 2018 +0300

    ms/mm/compaction: do not call suitable_migration_target() on every page
    
    suitable_migration_target() checks that pageblock is suitable for
    migration target.  In isolate_freepages_block(), it is called on every
    page and this is inefficient.  So make it called once per pageblock.
    
    suitable_migration_target() also checks if page is highorder or not, but
    it's criteria for highorder is pageblock order.  So calling it once
    within pageblock range has no problem.
    
    Signed-off-by: Joonsoo Kim <iamjoonsoo.kim at lge.com>
    Acked-by: Vlastimil Babka <vbabka at suse.cz>
    Cc: Mel Gorman <mgorman at suse.de>
    Cc: Rik van Riel <riel at redhat.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    (cherry picked from commit 01ead5340bcf5f3a1cd2452c75516d0ef4d908d7)
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/compaction.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 1faade458d38..c29883fe146d 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -247,6 +247,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 	struct page *cursor, *valid_page = NULL;
 	unsigned long flags;
 	bool locked = false;
+	bool checked_pageblock = false;
 
 	cursor = pfn_to_page(blockpfn);
 
@@ -278,8 +279,16 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
 			break;
 
 		/* Recheck this is a suitable migration target under lock */
-		if (!strict && !suitable_migration_target(page))
-			break;
+		if (!strict && !checked_pageblock) {
+			/*
+			 * We need to check suitability of pageblock only once
+			 * and this isolate_freepages_block() is called with
+			 * pageblock range, so just check once is sufficient.
+			 */
+			checked_pageblock = true;
+			if (!suitable_migration_target(page))
+				break;
+		}
 
 		/* Recheck this is a buddy page under lock */
 		if (!PageBuddy(page))


More information about the Devel mailing list