Commit 093b8ab7059129701849d3816f3d16f7b57fbfe0

Authored by Joonsoo Kim
Committed by Jiri Slaby
1 parent d9c7a696a1

mm/compaction: do not call suitable_migration_target() on every page

commit 01ead5340bcf5f3a1cd2452c75516d0ef4d908d7 upstream.

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@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 11 additions and 2 deletions Side-by-side Diff

... ... @@ -245,6 +245,7 @@
245 245 struct page *cursor, *valid_page = NULL;
246 246 unsigned long flags;
247 247 bool locked = false;
  248 + bool checked_pageblock = false;
248 249  
249 250 cursor = pfn_to_page(blockpfn);
250 251  
... ... @@ -276,8 +277,16 @@
276 277 break;
277 278  
278 279 /* Recheck this is a suitable migration target under lock */
279   - if (!strict && !suitable_migration_target(page))
280   - break;
  280 + if (!strict && !checked_pageblock) {
  281 + /*
  282 + * We need to check suitability of pageblock only once
  283 + * and this isolate_freepages_block() is called with
  284 + * pageblock range, so just check once is sufficient.
  285 + */
  286 + checked_pageblock = true;
  287 + if (!suitable_migration_target(page))
  288 + break;
  289 + }
281 290  
282 291 /* Recheck this is a buddy page under lock */
283 292 if (!PageBuddy(page))