diff mbox series

[v2,2/2] mm/compaction: avoid unneeded pageblock_end_pfn when no_set_skip_hint is set

Message ID 20230721150957.2058634-3-shikemeng@huawei.com (mailing list archive)
State New
Headers show
Series Two minor cleanups for compaction | expand

Commit Message

Kemeng Shi July 21, 2023, 3:09 p.m. UTC
Move pageblock_end_pfn after no_set_skip_hint check to avoid unneeded
pageblock_end_pfn if no_set_skip_hint is set.

Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/compaction.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

David Hildenbrand July 24, 2023, 12:17 p.m. UTC | #1
On 21.07.23 17:09, Kemeng Shi wrote:
> Move pageblock_end_pfn after no_set_skip_hint check to avoid unneeded
> pageblock_end_pfn if no_set_skip_hint is set.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huawei.com>
> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>   mm/compaction.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index c0d8d08fc163..9b7a0a69e19f 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -458,12 +458,12 @@ static void update_cached_migrate(struct compact_control *cc, unsigned long pfn)
>   {
>   	struct zone *zone = cc->zone;
>   
> -	pfn = pageblock_end_pfn(pfn);
> -
>   	/* Set for isolation rather than compaction */
>   	if (cc->no_set_skip_hint)
>   		return;
>   
> +	pfn = pageblock_end_pfn(pfn);
> +
>   	if (pfn > zone->compact_cached_migrate_pfn[0])
>   		zone->compact_cached_migrate_pfn[0] = pfn;
>   	if (cc->mode != MIGRATE_ASYNC &&

I'm pretty sure the compiler can to optimize this -- there should not be 
any function call involved, so the compiler can reorder as it pleases.

Anyhow, change itself looks good.

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/mm/compaction.c b/mm/compaction.c
index c0d8d08fc163..9b7a0a69e19f 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -458,12 +458,12 @@  static void update_cached_migrate(struct compact_control *cc, unsigned long pfn)
 {
 	struct zone *zone = cc->zone;
 
-	pfn = pageblock_end_pfn(pfn);
-
 	/* Set for isolation rather than compaction */
 	if (cc->no_set_skip_hint)
 		return;
 
+	pfn = pageblock_end_pfn(pfn);
+
 	if (pfn > zone->compact_cached_migrate_pfn[0])
 		zone->compact_cached_migrate_pfn[0] = pfn;
 	if (cc->mode != MIGRATE_ASYNC &&