On 26.07.24 02:36, Wei Yang wrote:
Total memory represents pages managed by buddy system. After the
introduction of DEFERRED_STRUCT_PAGE_INIT, it may count the pages before
being managed.
free_low_memory_core_early() returns number of pages for all free pages,
even at this moment only early initialized pages are freed to buddy
system. This means the total memory at this moment is not correct.
Let's increase it when pages are freed to buddy system.
Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
CC: David Hildenbrand <david@xxxxxxxxxx>
[...]
index 71d2716a554f..4701bc442df6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1248,16 +1248,14 @@ void __meminit __free_pages_core(struct page *page, unsigned int order,
* map it first.
*/
debug_pagealloc_map_pages(page, nr_pages);
- adjust_managed_page_count(page, nr_pages);
} else {
for (loop = 0; loop < nr_pages; loop++, p++) {
__ClearPageReserved(p);
set_page_count(p, 0);
}
- /* memblock adjusts totalram_pages() manually. */
- atomic_long_add(nr_pages, &page_zone(page)->managed_pages);
}
+ adjust_managed_page_count(page, nr_pages);
if (page_contains_unaccepted(page, order)) {
if (order == MAX_PAGE_ORDER && __free_unaccepted(page))
Nice!
Acked-by: David Hildenbrand <david@xxxxxxxxxx>
--
Cheers,
David / dhildenb