Skip to content

Commit 56d48d8

Browse files
Baolin Wangakpm00
authored andcommitted
mm: compaction: consider the number of scanning compound pages in isolate fail path
commit b717d6b ("mm: compaction: include compound page count for scanning in pageblock isolation") added compound page statistics for scanning in pageblock isolation, to make sure the number of scanned pages is always larger than the number of isolated pages when isolating mirgratable or free pageblock. However, when failing to isolate the pages when scanning the migratable or free pageblocks, the isolation failure path did not consider the scanning statistics of the compound pages, which result in showing the incorrect number of scanned pages in tracepoints or in vmstats which will confuse people about the page scanning pressure in memory compaction. Thus we should take into account the number of scanning pages when failing to isolate the compound pages to make the statistics accurate. Link: https://lkml.kernel.org/r/73d6250a90707649cc010731aedc27f946d722ed.1678962352.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang <[email protected]> Reviewed-by: Vlastimil Babka <[email protected]> Acked-by: Mel Gorman <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: William Lam <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 4bfbe37 commit 56d48d8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mm/compaction.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
586586
if (likely(order <= MAX_ORDER)) {
587587
blockpfn += (1UL << order) - 1;
588588
cursor += (1UL << order) - 1;
589+
nr_scanned += (1UL << order) - 1;
589590
}
590591
goto isolate_fail;
591592
}
@@ -904,6 +905,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
904905
if (ret == -EBUSY)
905906
ret = 0;
906907
low_pfn += compound_nr(page) - 1;
908+
nr_scanned += compound_nr(page) - 1;
907909
goto isolate_fail;
908910
}
909911

@@ -938,8 +940,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
938940
* a valid page order. Consider only values in the
939941
* valid order range to prevent low_pfn overflow.
940942
*/
941-
if (freepage_order > 0 && freepage_order <= MAX_ORDER)
943+
if (freepage_order > 0 && freepage_order <= MAX_ORDER) {
942944
low_pfn += (1UL << freepage_order) - 1;
945+
nr_scanned += (1UL << freepage_order) - 1;
946+
}
943947
continue;
944948
}
945949

@@ -954,8 +958,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
954958
if (PageCompound(page) && !cc->alloc_contig) {
955959
const unsigned int order = compound_order(page);
956960

957-
if (likely(order <= MAX_ORDER))
961+
if (likely(order <= MAX_ORDER)) {
958962
low_pfn += (1UL << order) - 1;
963+
nr_scanned += (1UL << order) - 1;
964+
}
959965
goto isolate_fail;
960966
}
961967

@@ -1077,6 +1083,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
10771083
*/
10781084
if (unlikely(PageCompound(page) && !cc->alloc_contig)) {
10791085
low_pfn += compound_nr(page) - 1;
1086+
nr_scanned += compound_nr(page) - 1;
10801087
SetPageLRU(page);
10811088
goto isolate_fail_put;
10821089
}

0 commit comments

Comments
 (0)