diff mbox series

[2/4] mm, compaction: Check if a page has been captured before draining PCP pages

Message ID 20230125134434.18017-3-mgorman@techsingularity.net (mailing list archive)
State New
Headers show
Series Fix excessive CPU usage during compaction | expand

Commit Message

Mel Gorman Jan. 25, 2023, 1:44 p.m. UTC
If a page has been captured then draining is unnecssary so check first
for a captured page.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 mm/compaction.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Vlastimil Babka Feb. 7, 2023, 4:53 p.m. UTC | #1
On 1/25/23 14:44, Mel Gorman wrote:
> If a page has been captured then draining is unnecssary so check first
> for a captured page.
> 
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>

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

> ---
>  mm/compaction.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c018b0e65720..28711a21a8a2 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -2441,6 +2441,12 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
>  			}
>  		}
>  
> +		/* Stop if a page has been captured */
> +		if (capc && capc->page) {
> +			ret = COMPACT_SUCCESS;
> +			break;
> +		}
> +
>  check_drain:
>  		/*
>  		 * Has the migration scanner moved away from the previous
> @@ -2459,12 +2465,6 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
>  				last_migrated_pfn = 0;
>  			}
>  		}
> -
> -		/* Stop if a page has been captured */
> -		if (capc && capc->page) {
> -			ret = COMPACT_SUCCESS;
> -			break;
> -		}
>  	}
>  
>  out:
diff mbox series

Patch

diff --git a/mm/compaction.c b/mm/compaction.c
index c018b0e65720..28711a21a8a2 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2441,6 +2441,12 @@  compact_zone(struct compact_control *cc, struct capture_control *capc)
 			}
 		}
 
+		/* Stop if a page has been captured */
+		if (capc && capc->page) {
+			ret = COMPACT_SUCCESS;
+			break;
+		}
+
 check_drain:
 		/*
 		 * Has the migration scanner moved away from the previous
@@ -2459,12 +2465,6 @@  compact_zone(struct compact_control *cc, struct capture_control *capc)
 				last_migrated_pfn = 0;
 			}
 		}
-
-		/* Stop if a page has been captured */
-		if (capc && capc->page) {
-			ret = COMPACT_SUCCESS;
-			break;
-		}
 	}
 
 out: