diff mbox series

[v2,01/16] mm/page_alloc: Cache page_zone() result in free_unref_page()

Message ID 20220809171854.3725722-2-willy@infradead.org (mailing list archive)
State New
Headers show
Series Allocate and free frozen pages | expand

Commit Message

Matthew Wilcox Aug. 9, 2022, 5:18 p.m. UTC
Save 17 bytes of text by calculating page_zone() once instead of twice.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/page_alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Miaohe Lin Aug. 10, 2022, 1:56 a.m. UTC | #1
On 2022/8/10 1:18, Matthew Wilcox (Oracle) wrote:
> Save 17 bytes of text by calculating page_zone() once instead of twice.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Thanks.

> ---
>  mm/page_alloc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index e5486d47406e..2745865a57c5 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3483,16 +3483,16 @@ void free_unref_page(struct page *page, unsigned int order)
>  	 * areas back if necessary. Otherwise, we may have to free
>  	 * excessively into the page allocator
>  	 */
> +	zone = page_zone(page);
>  	migratetype = get_pcppage_migratetype(page);
>  	if (unlikely(migratetype >= MIGRATE_PCPTYPES)) {
>  		if (unlikely(is_migrate_isolate(migratetype))) {
> -			free_one_page(page_zone(page), page, pfn, order, migratetype, FPI_NONE);
> +			free_one_page(zone, page, pfn, order, migratetype, FPI_NONE);
>  			return;
>  		}
>  		migratetype = MIGRATE_MOVABLE;
>  	}
>  
> -	zone = page_zone(page);
>  	pcp_trylock_prepare(UP_flags);
>  	pcp = pcp_spin_trylock_irqsave(zone->per_cpu_pageset, flags);
>  	if (pcp) {
>
Muchun Song Aug. 10, 2022, 6:31 a.m. UTC | #2
> On Aug 10, 2022, at 01:18, Matthew Wilcox (Oracle) <willy@infradead.org> wrote:
> 
> Save 17 bytes of text by calculating page_zone() once instead of twice.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.
Mel Gorman Aug. 10, 2022, 3 p.m. UTC | #3
On Tue, Aug 09, 2022 at 06:18:39PM +0100, Matthew Wilcox (Oracle) wrote:
> Save 17 bytes of text by calculating page_zone() once instead of twice.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Acked-by: Mel Gorman <mgorman@techsinguularity.net>
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e5486d47406e..2745865a57c5 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3483,16 +3483,16 @@  void free_unref_page(struct page *page, unsigned int order)
 	 * areas back if necessary. Otherwise, we may have to free
 	 * excessively into the page allocator
 	 */
+	zone = page_zone(page);
 	migratetype = get_pcppage_migratetype(page);
 	if (unlikely(migratetype >= MIGRATE_PCPTYPES)) {
 		if (unlikely(is_migrate_isolate(migratetype))) {
-			free_one_page(page_zone(page), page, pfn, order, migratetype, FPI_NONE);
+			free_one_page(zone, page, pfn, order, migratetype, FPI_NONE);
 			return;
 		}
 		migratetype = MIGRATE_MOVABLE;
 	}
 
-	zone = page_zone(page);
 	pcp_trylock_prepare(UP_flags);
 	pcp = pcp_spin_trylock_irqsave(zone->per_cpu_pageset, flags);
 	if (pcp) {