memblock: Uniform initialization all reserved pages to MIGRATE_MOVABLE
PATCH 1/1 memblock: Uniform initialization all reserved pages to MIGRATE_MOVABLE
Currently when CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set, the reserved pages are initialized to MIGRATE_MOVABLE by default in memmap_init.
Reserved memory mainly stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed.
Before this patch:
when CONFIG_DEFERRED_STRUCT_PAGE_INIT is not set, the freed memory was placed on the Movable list;
When CONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list.
After this patch, the freed memory is placed on the Movable list regardless of whether CONFIG_DEFERRED_STRUCT_PAGE_INIT is set.
Eg:
echo 500000 > /proc/sys/vm/nr_hugepages
cat /proc/pagetypeinfo
before:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…
Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0
Unmovable ≈ 15GB
after:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…
Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0
--- mm/mm_init.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/mm_init.c +4 -0
@@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid)if (zone_spans_pfn (zone, pfn))break ; } + +if (pageblock_aligned (pfn)) +set_pageblock_migratetype (pfn_to_page (pfn),MIGRATE_MOVABLE ); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); }#else
Signature · 1 line
2.34.1
Quoted 33 lines · suhua
Currently when
CONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the reserved pages are initialized toMIGRATE_MOVABLEby default inmemmap_init.Reserved memory mainly stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed.
Before this patch:
whenCONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the freed memory was placed on the Movable list;
WhenCONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list.After this patch, the freed memory is placed on the Movable list regardless of whether
CONFIG_DEFERRED_STRUCT_PAGE_INITis set.Eg:
echo 500000 >/proc/sys/vm/nr_hugepages
cat/proc/pagetypeinfobefore:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Unmovable ≈ 15GB
after:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…
Quoted 7 lines
Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Signed-off-by suhua <[email protected]>
Looks good to me.
Quoted 22 lines
---
mm/mm_init.c| 4 ++++1 file changed, 4 insertions(+)mm/mm_init.c +4
-0@@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid)if (zone_spans_pfn (zone, pfn))break ; } + +if (pageblock_aligned (pfn)) +set_pageblock_migratetype (pfn_to_page (pfn),MIGRATE_MOVABLE ); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); }#else Signature · 1 line
2.34.1
Signature · 2 lines
Wei Yang Help you, Help me
Mike Rapoport
maintainerQuoted 1 line · suhua
Subject: memblock: Uniform initialization all reserved pages to
MIGRATE_MOVABLE
I'd suggest:
memblock: uniformly initialize all reserved pages to MIGRATE_MOVABLE
Quoted 6 lines
Currently when
CONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the reserved pages are initialized toMIGRATE_MOVABLEby default inmemmap_init.Reserved memory mainly stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed.
The struct page metadata is not freed with HVO, it is rather pages used for vmemmap.
Quoted 10 lines
Before this patch:
whenCONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the freed memory was placed on the Movable list;
WhenCONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list.After this patch, the freed memory is placed on the Movable list regardless of whether
CONFIG_DEFERRED_STRUCT_PAGE_INITis set.Eg:
Please add back the description of the hardware used for this test and how much huge pages were allocated at boot.
Quoted 16 lines
echo 500000 >
/proc/sys/vm/nr_hugepages
cat/proc/pagetypeinfobefore:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Unmovable ≈ 15GB
after:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…
Quoted 7 lines
Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Signed-off-by suhua <[email protected]>
checkpatch.pl gives this warning:
WARNING: From:/Signed-off-by: email address mismatch: 'From: suhua <[email protected]>' != 'Signed-off-by: suhua <[email protected]>' Please update the commit authorship or signed-off to match.
Also, Signed-off-by should use a known identity, i.e. Name Lastname.
Quoted 22 lines
--- mm/mm_init.c | 4 ++++ 1 file changed, 4 insertions(+)mm/mm_init.c +4
-0@@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid)if (zone_spans_pfn (zone, pfn))break ; } + +if (pageblock_aligned (pfn)) +set_pageblock_migratetype (pfn_to_page (pfn),MIGRATE_MOVABLE ); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); }#else Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 6 lines · suhua
Quoted 1 line
Subject: memblock: Uniform initialization all reserved pages to
MIGRATE_MOVABLEI'd suggest:
memblock: uniformly initialize all reserved pages to
MIGRATE_MOVABLE
Thanks for the correction.
Quoted 9 lines
Quoted 6 lines
Currently when
CONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the reserved pages are initialized toMIGRATE_MOVABLEby default inmemmap_init.Reserved memory mainly stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed.
The struct page metadata is not freed with HVO, it is rather pages used for vmemmap.
Yes, I will update the description.
Quoted 6 lines
Quoted 6 lines
Before this patch:
whenCONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the freed memory was placed on the Movable list;
WhenCONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list.
Quoted 7 lines
Quoted 4 lines
After this patch, the freed memory is placed on the Movable list regardless of whether
CONFIG_DEFERRED_STRUCT_PAGE_INITis set.Eg:
Please add back the description of the hardware used for this test and how much huge pages were allocated at boot.
Well, the new patch will add this information.
Quoted 22 lines
Quoted 22 lines
echo 500000 >
/proc/sys/vm/nr_hugepages
cat/proc/pagetypeinfobefore:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Unmovable ≈ 15GB
after:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0
Quoted 8 lines
Quoted 1 line
Signed-off-by suhua <[email protected]>checkpatch.pl gives this warning:
WARNING: From:/Signed-off-by: email address mismatch: 'From: suhua <[email protected]>' != 'Signed-off-by: suhua <[email protected]>' Please update the commit authorship or signed-off to match.
Also, Signed-off-by should use a known identity, i.e. Name Lastname.
Oh, this is my oversight.
Quoted 14 lines
Quoted 14 lines
--- mm/mm_init.c | 4 ++++ 1 file changed, 4 insertions(+)mm/mm_init.c +2
-0@@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid)if (zone_spans_pfn (zone, pfn))break ; } + +if (pageblock_aligned (pfn))
Quoted 8 lines
Quoted 8 lines
mm/mm_init.c +2
-1+set_pageblock_migratetype (pfn_to_page (pfn),MIGRATE_MOVABLE ); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); }#else --2.34.1
Sincerely yours,
Su
Quoted 89 lines · Mike Rapoport <[email protected]> 于2024年10月20日周日 15:15写道:
Quoted 1 line · suhua
Subject: memblock: Uniform initialization all reserved pages to
MIGRATE_MOVABLEI'd suggest:
memblock: uniformly initialize all reserved pages to
MIGRATE_MOVABLEQuoted 6 lines
Currently when
CONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the reserved pages are initialized toMIGRATE_MOVABLEby default inmemmap_init.Reserved memory mainly stores the metadata of struct page. When HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON=Y and hugepages are allocated, the memory occupied by the struct page metadata will be freed.
The struct page metadata is not freed with HVO, it is rather pages used for vmemmap.
Quoted 10 lines
Before this patch:
whenCONFIG_DEFERRED_STRUCT_PAGE_INITis not set, the freed memory was placed on the Movable list;
WhenCONFIG_DEFERRED_STRUCT_PAGE_INIT=Y, the freed memory was placed on the Unmovable list.After this patch, the freed memory is placed on the Movable list regardless of whether
CONFIG_DEFERRED_STRUCT_PAGE_INITis set.Eg:
Please add back the description of the hardware used for this test and how much huge pages were allocated at boot.
Quoted 16 lines
echo 500000 >
/proc/sys/vm/nr_hugepages
cat/proc/pagetypeinfobefore:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Node 0, zone Normal, type Unmovable 51 2 1 28 53 35 35 43 40 69 3852 Node 0, zone Normal, type Movable 6485 4610 666 202 200 185 208 87 54 2 240 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Unmovable ≈ 15GB
after:
Free pages count per migrate type at order 0 1 2 3 4 5 6 7 8 9 10
…Quoted 7 lines
Node 0, zone Normal, type Unmovable 0 1 1 0 0 0 0 1 1 1 0 Node 0, zone Normal, type Movable 1563 4107 1119 189 256 368 286 132 109 4 3841 Node 0, zone Normal, type Reclaimable 2 2 1 23 13 1 2 1 0 1 0 Node 0, zone Normal, type HighAtomic 0 0 0 0 0 0 0 0 0 0 0 Node 0, zone Normal, type Isolate 0 0 0 0 0 0 0 0 0 0 0Signed-off-by suhua <[email protected]>checkpatch.pl gives this warning:
WARNING: From:/Signed-off-by: email address mismatch: 'From: suhua <[email protected]>' != 'Signed-off-by: suhua <[email protected]>' Please update the commit authorship or signed-off to match.
Also, Signed-off-by should use a known identity, i.e. Name Lastname.
Quoted 20 lines
--- mm/mm_init.c | 4 ++++ 1 file changed, 4 insertions(+)mm/mm_init.c +4
-1@@ -722,6 +722,10 @@ static void __meminit init_reserved_page(unsigned long pfn, int nid)if (zone_spans_pfn (zone, pfn))break ; } + +if (pageblock_aligned (pfn)) +set_pageblock_migratetype (pfn_to_page (pfn),MIGRATE_MOVABLE ); + __init_single_page(pfn_to_page(pfn), pfn, zid, nid); }#else --Quoted 2 lines
2.34.1
--
Sincerely yours,
Mike.