Skip to content

Commit 590ccea

Browse files
gormanmakpm00
authored andcommitted
mm: compaction: update pageblock skip when first migration candidate is not at the start
isolate_migratepages_block should mark a pageblock as skip if scanning started on an aligned pageblock boundary but it only updates the skip flag if the first migration candidate is also aligned. Tracing during a compaction stress load (mmtests: workload-usemem-stress-numa-compact) that many pageblocks are not marked skip causing excessive scanning of blocks that had been recently checked. Update pageblock skip based on "valid_page" which is set if scanning started on a pageblock boundary. [[email protected]: fix handling of skip bit] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Mel Gorman <[email protected]> Tested-by: Raghavendra K T <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Chuyi Zhou <[email protected]> Cc: Jiri Slaby <[email protected]> Cc: Maxim Levitsky <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Pedro Falcato <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9ecc5fc commit 590ccea

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

mm/compaction.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,14 @@ void reset_isolation_suitable(pg_data_t *pgdat)
392392
* Sets the pageblock skip bit if it was clear. Note that this is a hint as
393393
* locks are not required for read/writers. Returns true if it was already set.
394394
*/
395-
static bool test_and_set_skip(struct compact_control *cc, struct page *page,
396-
unsigned long pfn)
395+
static bool test_and_set_skip(struct compact_control *cc, struct page *page)
397396
{
398397
bool skip;
399398

400-
/* Do no update if skip hint is being ignored */
399+
/* Do not update if skip hint is being ignored */
401400
if (cc->ignore_skip_hint)
402401
return false;
403402

404-
if (!pageblock_aligned(pfn))
405-
return false;
406-
407403
skip = get_pageblock_skip(page);
408404
if (!skip && !cc->no_set_skip_hint)
409405
set_pageblock_skip(page);
@@ -470,8 +466,7 @@ static void update_cached_migrate(struct compact_control *cc, unsigned long pfn)
470466
{
471467
}
472468

473-
static bool test_and_set_skip(struct compact_control *cc, struct page *page,
474-
unsigned long pfn)
469+
static bool test_and_set_skip(struct compact_control *cc, struct page *page)
475470
{
476471
return false;
477472
}
@@ -1074,11 +1069,17 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
10741069

10751070
lruvec_memcg_debug(lruvec, page_folio(page));
10761071

1077-
/* Try get exclusive access under lock */
1078-
if (!skip_updated) {
1072+
/*
1073+
* Try get exclusive access under lock. If marked for
1074+
* skip, the scan is aborted unless the current context
1075+
* is a rescan to reach the end of the pageblock.
1076+
*/
1077+
if (!skip_updated && valid_page) {
10791078
skip_updated = true;
1080-
if (test_and_set_skip(cc, page, low_pfn))
1079+
if (test_and_set_skip(cc, valid_page) &&
1080+
!cc->finish_pageblock) {
10811081
goto isolate_abort;
1082+
}
10821083
}
10831084

10841085
/*

0 commit comments

Comments
 (0)