[PATCH 3/5] mm/compaction: merge end_pfn boundary check in isolate_freepages_range

Kemeng Shi posted 5 patches 2 years, 6 months ago
There is a newer version of this series
[PATCH 3/5] mm/compaction: merge end_pfn boundary check in isolate_freepages_range
Posted by Kemeng Shi 2 years, 6 months ago
From: Kemeng Shi <shikemeng@huawei.com>

Merge the end_pfn boundary check for single page block forward and multiple
page blocks forward to avoid do twice boundary check for multiple page
blocks forward.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
 mm/compaction.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index 4a784872565a..65791a74c5e8 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -740,8 +740,6 @@ isolate_freepages_range(struct compact_control *cc,
 		/* Protect pfn from changing by isolate_freepages_block */
 		unsigned long isolate_start_pfn = pfn;
 
-		block_end_pfn = min(block_end_pfn, end_pfn);
-
 		/*
 		 * pfn could pass the block_end_pfn if isolated freepage
 		 * is more than pageblock order. In this case, we adjust
@@ -750,9 +748,10 @@ isolate_freepages_range(struct compact_control *cc,
 		if (pfn >= block_end_pfn) {
 			block_start_pfn = pageblock_start_pfn(pfn);
 			block_end_pfn = pageblock_end_pfn(pfn);
-			block_end_pfn = min(block_end_pfn, end_pfn);
 		}
 
+		block_end_pfn = min(block_end_pfn, end_pfn);
+
 		if (!pageblock_pfn_to_page(block_start_pfn,
 					block_end_pfn, cc->zone))
 			break;
-- 
2.30.0
Re: [PATCH 3/5] mm/compaction: merge end_pfn boundary check in isolate_freepages_range
Posted by Baolin Wang 2 years, 6 months ago

On 7/30/2023 1:43 AM, Kemeng Shi wrote:
> From: Kemeng Shi <shikemeng@huawei.com>
> 
> Merge the end_pfn boundary check for single page block forward and multiple
> page blocks forward to avoid do twice boundary check for multiple page
> blocks forward.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

> ---
>   mm/compaction.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 4a784872565a..65791a74c5e8 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -740,8 +740,6 @@ isolate_freepages_range(struct compact_control *cc,
>   		/* Protect pfn from changing by isolate_freepages_block */
>   		unsigned long isolate_start_pfn = pfn;
>   
> -		block_end_pfn = min(block_end_pfn, end_pfn);
> -
>   		/*
>   		 * pfn could pass the block_end_pfn if isolated freepage
>   		 * is more than pageblock order. In this case, we adjust
> @@ -750,9 +748,10 @@ isolate_freepages_range(struct compact_control *cc,
>   		if (pfn >= block_end_pfn) {
>   			block_start_pfn = pageblock_start_pfn(pfn);
>   			block_end_pfn = pageblock_end_pfn(pfn);
> -			block_end_pfn = min(block_end_pfn, end_pfn);
>   		}
>   
> +		block_end_pfn = min(block_end_pfn, end_pfn);
> +
>   		if (!pageblock_pfn_to_page(block_start_pfn,
>   					block_end_pfn, cc->zone))
>   			break;