linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/page_alloc: merge two get_pfnblock_migratetype() into one
@ 2022-11-23 13:40 wonder_rock
  2022-11-23 15:45 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: wonder_rock @ 2022-11-23 13:40 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Deyan Wang

From: Deyan Wang <wonder_rock@126.com>

It is safe to get_pfnblock_migratetype() in critical section,
so just call get_pfnblock_migratetype() once.

Signed-off-by: Deyan Wang <wonder_rock@126.com>
---
 mm/page_alloc.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6652df1f5cc8..c7ba9d65d1c0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1704,13 +1704,8 @@ static void __free_pages_ok(struct page *page, unsigned int order,
 	if (!free_pages_prepare(page, order, true, fpi_flags))
 		return;
 
-	migratetype = get_pfnblock_migratetype(page, pfn);
-
 	spin_lock_irqsave(&zone->lock, flags);
-	if (unlikely(has_isolate_pageblock(zone) ||
-		is_migrate_isolate(migratetype))) {
-		migratetype = get_pfnblock_migratetype(page, pfn);
-	}
+	migratetype = get_pfnblock_migratetype(page, pfn);
 	__free_one_page(page, pfn, zone, order, migratetype, fpi_flags);
 	spin_unlock_irqrestore(&zone->lock, flags);
 
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] mm/page_alloc: merge two get_pfnblock_migratetype() into one
  2022-11-23 13:40 [PATCH 1/1] mm/page_alloc: merge two get_pfnblock_migratetype() into one wonder_rock
@ 2022-11-23 15:45 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2022-11-23 15:45 UTC (permalink / raw)
  To: wonder_rock; +Cc: akpm, linux-mm, linux-kernel

On Wed, Nov 23, 2022 at 09:40:43PM +0800, wonder_rock@126.com wrote:
> From: Deyan Wang <wonder_rock@126.com>
> 
> It is safe to get_pfnblock_migratetype() in critical section,
> so just call get_pfnblock_migratetype() once.

No, you don't understand.  zone->lock is HOT and we want to avoid
calling get_pfnblock_migratetype() under the lock, if we can avoid it.
Which we usually can.

> Signed-off-by: Deyan Wang <wonder_rock@126.com>
> ---
>  mm/page_alloc.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 6652df1f5cc8..c7ba9d65d1c0 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1704,13 +1704,8 @@ static void __free_pages_ok(struct page *page, unsigned int order,
>  	if (!free_pages_prepare(page, order, true, fpi_flags))
>  		return;
>  
> -	migratetype = get_pfnblock_migratetype(page, pfn);
> -
>  	spin_lock_irqsave(&zone->lock, flags);
> -	if (unlikely(has_isolate_pageblock(zone) ||
> -		is_migrate_isolate(migratetype))) {
> -		migratetype = get_pfnblock_migratetype(page, pfn);
> -	}
> +	migratetype = get_pfnblock_migratetype(page, pfn);
>  	__free_one_page(page, pfn, zone, order, migratetype, fpi_flags);
>  	spin_unlock_irqrestore(&zone->lock, flags);
>  
> -- 
> 2.25.1
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-23 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-23 13:40 [PATCH 1/1] mm/page_alloc: merge two get_pfnblock_migratetype() into one wonder_rock
2022-11-23 15:45 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).