Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/mm: Get total ram pages from memblock

On s390, zero page's size relies on total ram pages.

Since we plan to move the accounting into __free_pages_core(),
totalram_pages may not represent the total usable pages on system
at this point when defer_init is enabled.

We can get the total usable pages from memblock directly. The size maybe
not accurate due to the alignment, but enough for the calculation.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Mike Rapoport (IBM) <rppt@kernel.org>
CC: David Hildenbrand <david@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20240616013537.20338-1-richard.weiyang@gmail.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Wei Yang and committed by
Alexander Gordeev
37db17c1 7c679286

+2 -1
+2 -1
arch/s390/mm/init.c
··· 62 62 63 63 static void __init setup_zero_pages(void) 64 64 { 65 + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size()); 65 66 unsigned int order; 66 67 struct page *page; 67 68 int i; ··· 71 70 order = 7; 72 71 73 72 /* Limit number of empty zero pages for small memory sizes */ 74 - while (order > 2 && (totalram_pages() >> 10) < (1UL << order)) 73 + while (order > 2 && (total_pages >> 10) < (1UL << order)) 75 74 order--; 76 75 77 76 empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);