Skip to content

Commit c122b20

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/compaction: check pageblock suitability once per pageblock
isolation_suitable() and migrate_async_suitable() is used to be sure that this pageblock range is fine to be migragted. It isn't needed to call it on every page. Current code do well if not suitable, but, don't do well when suitable. 1) It re-checks isolation_suitable() on each page of a pageblock that was already estabilished as suitable. 2) It re-checks migrate_async_suitable() on each page of a pageblock that was not entered through the next_pageblock: label, because last_pageblock_nr is not otherwise updated. This patch fixes situation by 1) calling isolation_suitable() only once per pageblock and 2) always updating last_pageblock_nr to the pageblock that was just checked. Additionally, move PageBuddy() check after pageblock unit check, since pageblock check is the first thing we should do and makes things more simple. [vbabka@suse.cz: rephrase commit description] Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Mel Gorman <mgorman@suse.de> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent be1aa03 commit c122b20

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

‎mm/compaction.c‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,25 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
526526

527527
/* If isolation recently failed, do not retry */
528528
pageblock_nr = low_pfn >> pageblock_order;
529-
if (!isolation_suitable(cc, page))
530-
goto next_pageblock;
529+
if (last_pageblock_nr != pageblock_nr) {
530+
int mt;
531+
532+
last_pageblock_nr = pageblock_nr;
533+
if (!isolation_suitable(cc, page))
534+
goto next_pageblock;
535+
536+
/*
537+
* For async migration, also only scan in MOVABLE
538+
* blocks. Async migration is optimistic to see if
539+
* the minimum amount of work satisfies the allocation
540+
*/
541+
mt = get_pageblock_migratetype(page);
542+
if (!cc->sync && !migrate_async_suitable(mt)) {
543+
cc->finished_update_migrate = true;
544+
skipped_async_unsuitable = true;
545+
goto next_pageblock;
546+
}
547+
}
531548

532549
/*
533550
* Skip if free. page_order cannot be used without zone->lock
@@ -536,18 +553,6 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
536553
if (PageBuddy(page))
537554
continue;
538555

539-
/*
540-
* For async migration, also only scan in MOVABLE blocks. Async
541-
* migration is optimistic to see if the minimum amount of work
542-
* satisfies the allocation
543-
*/
544-
if (!cc->sync && last_pageblock_nr != pageblock_nr &&
545-
!migrate_async_suitable(get_pageblock_migratetype(page))) {
546-
cc->finished_update_migrate = true;
547-
skipped_async_unsuitable = true;
548-
goto next_pageblock;
549-
}
550-
551556
/*
552557
* Check may be lockless but that's ok as we recheck later.
553558
* It's possible to migrate LRU pages and balloon pages
@@ -639,7 +644,6 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
639644

640645
next_pageblock:
641646
low_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages) - 1;
642-
last_pageblock_nr = pageblock_nr;
643647
}
644648

645649
acct_isolated(zone, locked, cc);

0 commit comments

Comments
 (0)