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

book3s64/hash: Disable debug_pagealloc if it requires more memory

Make size of the linear map to be allocated in RMA region to be of
ppc64_rma_size / 4. If debug_pagealloc requires more memory than that
then do not allocate any memory and disable debug_pagealloc.

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/e1ef66f32a1fe63bcbb89d5c11d86c65beef5ded.1729271995.git.ritesh.list@gmail.com

authored by

Ritesh Harjani (IBM) and committed by
Michael Ellerman
47dd2e63 685d942d

+14 -1
+14 -1
arch/powerpc/mm/book3s64/hash_utils.c
··· 331 331 static DEFINE_RAW_SPINLOCK(linear_map_hash_lock); 332 332 static inline void hash_debug_pagealloc_alloc_slots(void) 333 333 { 334 + unsigned long max_hash_count = ppc64_rma_size / 4; 335 + 334 336 if (!debug_pagealloc_enabled()) 335 337 return; 336 338 linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT; 339 + if (unlikely(linear_map_hash_count > max_hash_count)) { 340 + pr_info("linear map size (%llu) greater than 4 times RMA region (%llu). Disabling debug_pagealloc\n", 341 + ((u64)linear_map_hash_count << PAGE_SHIFT), 342 + ppc64_rma_size); 343 + linear_map_hash_count = 0; 344 + return; 345 + } 346 + 337 347 linear_map_hash_slots = memblock_alloc_try_nid( 338 348 linear_map_hash_count, 1, MEMBLOCK_LOW_LIMIT, 339 349 ppc64_rma_size, NUMA_NO_NODE); ··· 354 344 355 345 static inline void hash_debug_pagealloc_add_slot(phys_addr_t paddr, int slot) 356 346 { 357 - if (!debug_pagealloc_enabled()) 347 + if (!debug_pagealloc_enabled() || !linear_map_hash_count) 358 348 return; 359 349 if ((paddr >> PAGE_SHIFT) < linear_map_hash_count) 360 350 linear_map_hash_slots[paddr >> PAGE_SHIFT] = slot | 0x80; ··· 365 355 { 366 356 unsigned long flags, vaddr, lmi; 367 357 int i; 358 + 359 + if (!debug_pagealloc_enabled() || !linear_map_hash_count) 360 + return 0; 368 361 369 362 local_irq_save(flags); 370 363 for (i = 0; i < numpages; i++, page++) {