Commit fc8dc0a9f5b062d2b5fbfe368e4d9cdff23ca76b

Authored by Joonsoo Kim
Committed by Jiri Slaby
1 parent e45dcd3dea

mm/compaction: check pageblock suitability once per pageblock

commit c122b2087ab94192f2b937e47b563a9c4e688ece upstream.

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>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>

Showing 1 changed file with 19 additions and 15 deletions Side-by-side Diff

... ... @@ -527,26 +527,31 @@
527 527  
528 528 /* If isolation recently failed, do not retry */
529 529 pageblock_nr = low_pfn >> pageblock_order;
530   - if (!isolation_suitable(cc, page))
531   - goto next_pageblock;
  530 + if (last_pageblock_nr != pageblock_nr) {
  531 + int mt;
532 532  
  533 + last_pageblock_nr = pageblock_nr;
  534 + if (!isolation_suitable(cc, page))
  535 + goto next_pageblock;
  536 +
  537 + /*
  538 + * For async migration, also only scan in MOVABLE
  539 + * blocks. Async migration is optimistic to see if
  540 + * the minimum amount of work satisfies the allocation
  541 + */
  542 + mt = get_pageblock_migratetype(page);
  543 + if (!cc->sync && !migrate_async_suitable(mt)) {
  544 + cc->finished_update_migrate = true;
  545 + skipped_async_unsuitable = true;
  546 + goto next_pageblock;
  547 + }
  548 + }
  549 +
533 550 /* Skip if free */
534 551 if (PageBuddy(page))
535 552 continue;
536 553  
537 554 /*
538   - * For async migration, also only scan in MOVABLE blocks. Async
539   - * migration is optimistic to see if the minimum amount of work
540   - * satisfies the allocation
541   - */
542   - if (!cc->sync && last_pageblock_nr != pageblock_nr &&
543   - !migrate_async_suitable(get_pageblock_migratetype(page))) {
544   - cc->finished_update_migrate = true;
545   - skipped_async_unsuitable = true;
546   - goto next_pageblock;
547   - }
548   -
549   - /*
550 555 * Check may be lockless but that's ok as we recheck later.
551 556 * It's possible to migrate LRU pages and balloon pages
552 557 * Skip any other type of page
... ... @@ -637,7 +642,6 @@
637 642  
638 643 next_pageblock:
639 644 low_pfn = ALIGN(low_pfn + 1, pageblock_nr_pages) - 1;
640   - last_pageblock_nr = pageblock_nr;
641 645 }
642 646  
643 647 acct_isolated(zone, locked, cc);