linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn
@ 2024-05-22  7:29 Wei Yang
  2024-05-22  7:29 ` [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone Wei Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Yang @ 2024-05-22  7:29 UTC (permalink / raw)
  To: rppt, akpm; +Cc: linux-mm, Wei Yang

Just like what it does in "if (mirrored_kernelcore)", we should use
memblock_region_memory_base_pfn() to get the startpfn.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 include/linux/memblock.h | 2 +-
 mm/mm_init.c             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index e2082240586d..6cf18dc2b4d0 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -565,7 +565,7 @@ static inline unsigned long memblock_region_reserved_end_pfn(const struct memblo
 }
 
 /**
- * for_each_mem_region - itereate over memory regions
+ * for_each_mem_region - iterate over memory regions
  * @region: loop variable
  */
 #define for_each_mem_region(region)					\
diff --git a/mm/mm_init.c b/mm/mm_init.c
index f72b852bd5b8..2dfb87841fdb 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -363,7 +363,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
 
 			nid = memblock_get_region_node(r);
 
-			usable_startpfn = PFN_DOWN(r->base);
+			usable_startpfn = memblock_region_memory_base_pfn(r);
 			zone_movable_pfn[nid] = zone_movable_pfn[nid] ?
 				min(usable_startpfn, zone_movable_pfn[nid]) :
 				usable_startpfn;
-- 
2.34.1



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

* [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
  2024-05-22  7:29 [PATCH 1/2] mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn Wei Yang
@ 2024-05-22  7:29 ` Wei Yang
  2024-05-23 14:53   ` Mike Rapoport
  0 siblings, 1 reply; 4+ messages in thread
From: Wei Yang @ 2024-05-22  7:29 UTC (permalink / raw)
  To: rppt, akpm; +Cc: linux-mm, Wei Yang

Since we always populate low zones, it is not necessary to count
nr_initialised for them. Let's move the last zone check ahead to skip
the nr_initialised reset.

Assume low zones counts for 4G, this change may reduce 1M times
comparison of prev_end_pfn and end_pfn.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/mm_init.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 2dfb87841fdb..4cc627b4ebfe 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -676,6 +676,11 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
 
 	if (early_page_ext_enabled())
 		return false;
+
+	/* Always populate low zones for address-constrained allocations */
+	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
+		return false;
+
 	/*
 	 * prev_end_pfn static that contains the end of previous zone
 	 * No need to protect because called very early in boot before smp_init.
@@ -685,10 +690,6 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
 		nr_initialised = 0;
 	}
 
-	/* Always populate low zones for address-constrained allocations */
-	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
-		return false;
-
 	if (NODE_DATA(nid)->first_deferred_pfn != ULONG_MAX)
 		return true;
 	/*
-- 
2.34.1



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

* Re: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
  2024-05-22  7:29 ` [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone Wei Yang
@ 2024-05-23 14:53   ` Mike Rapoport
  2024-05-24  0:59     ` Wei Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Rapoport @ 2024-05-23 14:53 UTC (permalink / raw)
  To: Wei Yang; +Cc: akpm, linux-mm

On Wed, May 22, 2024 at 07:29:59AM +0000, Wei Yang wrote:
> Since we always populate low zones, it is not necessary to count
> nr_initialised for them. Let's move the last zone check ahead to skip
> the nr_initialised reset.

We also don't need to count initialized pfns after first_deferred_pfn is
detected, so the reset of nr_initialised can be moved even lower.

> Assume low zones counts for 4G, this change may reduce 1M times
> comparison of prev_end_pfn and end_pfn.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> ---
>  mm/mm_init.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 2dfb87841fdb..4cc627b4ebfe 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -676,6 +676,11 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
>  
>  	if (early_page_ext_enabled())
>  		return false;
> +
> +	/* Always populate low zones for address-constrained allocations */
> +	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
> +		return false;
> +
>  	/*
>  	 * prev_end_pfn static that contains the end of previous zone
>  	 * No need to protect because called very early in boot before smp_init.
> @@ -685,10 +690,6 @@ defer_init(int nid, unsigned long pfn, unsigned long end_pfn)
>  		nr_initialised = 0;
>  	}
>  
> -	/* Always populate low zones for address-constrained allocations */
> -	if (end_pfn < pgdat_end_pfn(NODE_DATA(nid)))
> -		return false;
> -
>  	if (NODE_DATA(nid)->first_deferred_pfn != ULONG_MAX)
>  		return true;
>  	/*
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.


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

* Re: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
  2024-05-23 14:53   ` Mike Rapoport
@ 2024-05-24  0:59     ` Wei Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2024-05-24  0:59 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Wei Yang, akpm, linux-mm

On Thu, May 23, 2024 at 05:53:09PM +0300, Mike Rapoport wrote:
>On Wed, May 22, 2024 at 07:29:59AM +0000, Wei Yang wrote:
>> Since we always populate low zones, it is not necessary to count
>> nr_initialised for them. Let's move the last zone check ahead to skip
>> the nr_initialised reset.
>
>We also don't need to count initialized pfns after first_deferred_pfn is
>detected, so the reset of nr_initialised can be moved even lower.
>

Agree, will update in v2.

-- 
Wei Yang
Help you, Help me


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

end of thread, other threads:[~2024-05-24  0:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22  7:29 [PATCH 1/2] mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn Wei Yang
2024-05-22  7:29 ` [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone Wei Yang
2024-05-23 14:53   ` Mike Rapoport
2024-05-24  0:59     ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox