diff mbox series

[1/4] mm: compaction: Ensure rescanning only happens on partially scanned pageblocks

Message ID 20230515113344.6869-2-mgorman@techsingularity.net (mailing list archive)
State New
Headers show
Series Follow-up "Fix excessive CPU usage during compaction" | expand

Commit Message

Mel Gorman May 15, 2023, 11:33 a.m. UTC
compact_zone() intends to rescan pageblocks if there is a failure to
migrate "within the current order-aligned block". However, the pageblock
scan may already be complete and moved to the next block causing the
next pageblock to be "rescanned". Ensure only the most recent pageblock
is rescanned.

Reported-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 mm/compaction.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Vlastimil Babka May 25, 2023, 9:57 a.m. UTC | #1
On 5/15/23 13:33, Mel Gorman wrote:
> compact_zone() intends to rescan pageblocks if there is a failure to
> migrate "within the current order-aligned block". However, the pageblock
> scan may already be complete and moved to the next block causing the
> next pageblock to be "rescanned". Ensure only the most recent pageblock
> is rescanned.
> 
> Reported-by: Vlastimil Babka <vbabka@suse.cz>
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/compaction.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c8bcdea15f5f..81791c124bb8 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -2464,8 +2464,9 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
>  			 * fast_find_migrateblock revisiting blocks that were
>  			 * recently partially scanned.
>  			 */
> -			if (cc->direct_compaction && !cc->finish_pageblock &&
> -						(cc->mode < MIGRATE_SYNC)) {
> +			if (!pageblock_aligned(cc->migrate_pfn) &&
> +			    cc->direct_compaction && !cc->finish_pageblock &&
> +			    (cc->mode < MIGRATE_SYNC)) {
>  				cc->finish_pageblock = true;
>  
>  				/*
diff mbox series

Patch

diff --git a/mm/compaction.c b/mm/compaction.c
index c8bcdea15f5f..81791c124bb8 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2464,8 +2464,9 @@  compact_zone(struct compact_control *cc, struct capture_control *capc)
 			 * fast_find_migrateblock revisiting blocks that were
 			 * recently partially scanned.
 			 */
-			if (cc->direct_compaction && !cc->finish_pageblock &&
-						(cc->mode < MIGRATE_SYNC)) {
+			if (!pageblock_aligned(cc->migrate_pfn) &&
+			    cc->direct_compaction && !cc->finish_pageblock &&
+			    (cc->mode < MIGRATE_SYNC)) {
 				cc->finish_pageblock = true;
 
 				/*