mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn
PATCH 1/2 mm/mm_init.c: use memblock_region_memory_base_pfn() to get startpfn
Just like what it does in "if (mirrored_kernelcore)", we should use memblock_region_memory_base_pfn() to get the startpfn.
--- include/linux/memblock.h | 2 +- mm/mm_init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/memblock.h +1 -1
@@ -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) \
mm/mm_init.c +1 -1
@@ -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;
Signature · 1 line
2.34.1
PATCH 2/2 mm/mm_init.c: count nr_initialised only for last zone
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.
--- mm/mm_init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
mm/mm_init.c +5 -4
@@ -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;/*
Signature · 1 line
2.34.1
Mike Rapoport
maintainerRe: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
Quoted 3 lines · Wei Yang
Since we always populate low zones, it is not necessary to count
nr_initialisedfor them. Let's move the last zone check ahead to skip thenr_initialisedreset.
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.
Quoted 38 lines
Assume low zones counts for 4G, this change may reduce 1M times comparison of
prev_end_pfnandend_pfn.Signed-off-by Wei Yang <[email protected]>--- mm/mm_init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)mm/mm_init.c +5
-4@@ -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;/* Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Re: [PATCH 2/2] mm/mm_init.c: count nr_initialised only for last zone
Quoted 8 lines · Mike Rapoport
Quoted 3 lines · Wei Yang
Since we always populate low zones, it is not necessary to count
nr_initialisedfor them. Let's move the last zone check ahead to skip thenr_initialisedreset.We also don't need to count initialized pfns after
first_deferred_pfnis detected, so the reset ofnr_initialisedcan be moved even lower.
Agree, will update in v2.
Signature · 2 lines
Wei Yang Help you, Help me