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

s390/boot: Add physmem tracking debug support

Introduce boot_debug() calls to track memory detection, online ranges,
reserved areas, and allocations (except for VMEM allocations, which are
too frequent). Instead introduce dump_physmem_reserved() function which
prints out full memory tracking information. This helps in debugging
early boot memory handling.

Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Vasily Gorbik and committed by
Alexander Gordeev
9688b17b d2ebe06b

+51 -8
+1
arch/s390/boot/boot.h
··· 57 57 unsigned long align, unsigned long min, unsigned long max, 58 58 bool die_on_oom); 59 59 unsigned long get_physmem_alloc_pos(void); 60 + void dump_physmem_reserved(void); 60 61 bool ipl_report_certs_intersects(unsigned long addr, unsigned long size, 61 62 unsigned long *intersection_start); 62 63 bool is_ipl_block_dump(void);
+45 -4
arch/s390/boot/physmem_info.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 + #define boot_fmt(fmt) "physmem: " fmt 2 3 #include <linux/processor.h> 3 4 #include <linux/errno.h> 4 5 #include <linux/init.h> ··· 29 28 return &physmem_info.online[n]; 30 29 if (unlikely(!physmem_info.online_extended)) { 31 30 physmem_info.online_extended = (struct physmem_range *)physmem_alloc_range( 32 - RR_MEM_DETECT_EXTENDED, ENTRIES_EXTENDED_MAX, sizeof(long), 0, 31 + RR_MEM_DETECT_EXT, ENTRIES_EXTENDED_MAX, sizeof(long), 0, 33 32 physmem_alloc_pos, true); 34 33 } 35 34 return &physmem_info.online_extended[n - MEM_INLINED_ENTRIES]; ··· 208 207 max_physmem_end = search_mem_end(); 209 208 physmem_info.info_source = MEM_DETECT_BIN_SEARCH; 210 209 } 210 + boot_debug("Max physical memory: 0x%016lx (info source: %s)\n", max_physmem_end, 211 + get_physmem_info_source()); 211 212 return max_physmem_end; 212 213 } 213 214 214 215 void detect_physmem_online_ranges(unsigned long max_physmem_end) 215 216 { 217 + unsigned long start, end; 218 + int i; 219 + 216 220 if (!sclp_early_read_storage_info()) { 217 221 physmem_info.info_source = MEM_DETECT_SCLP_STOR_INFO; 218 222 } else if (physmem_info.info_source == MEM_DETECT_DIAG500_STOR_LIMIT) { ··· 232 226 } else if (max_physmem_end) { 233 227 add_physmem_online_range(0, max_physmem_end); 234 228 } 229 + boot_debug("Online memory ranges (info source: %s):\n", get_physmem_info_source()); 230 + for_each_physmem_online_range(i, &start, &end) 231 + boot_debug(" online [%d]: 0x%016lx-0x%016lx\n", i, start, end); 235 232 } 236 233 237 234 void physmem_set_usable_limit(unsigned long limit) 238 235 { 239 236 physmem_info.usable = limit; 240 237 physmem_alloc_pos = limit; 238 + boot_debug("Usable memory limit: 0x%016lx\n", limit); 241 239 } 242 240 243 241 static void die_oom(unsigned long size, unsigned long align, unsigned long min, unsigned long max) ··· 275 265 disabled_wait(); 276 266 } 277 267 278 - void physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size) 268 + static void _physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size) 279 269 { 280 270 physmem_info.reserved[type].start = addr; 281 271 physmem_info.reserved[type].end = addr + size; 282 272 } 283 273 274 + void physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size) 275 + { 276 + _physmem_reserve(type, addr, size); 277 + boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Reserve:", addr, addr + size, 278 + get_rr_type_name(type)); 279 + } 280 + 284 281 void physmem_free(enum reserved_range_type type) 285 282 { 283 + boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Free:", physmem_info.reserved[type].start, 284 + physmem_info.reserved[type].end, get_rr_type_name(type)); 286 285 physmem_info.reserved[type].start = 0; 287 286 physmem_info.reserved[type].end = 0; 288 287 } ··· 358 339 max = min(max, physmem_alloc_pos); 359 340 addr = __physmem_alloc_range(size, align, min, max, 0, NULL, die_on_oom); 360 341 if (addr) 361 - physmem_reserve(type, addr, size); 342 + _physmem_reserve(type, addr, size); 343 + boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Alloc range:", addr, addr + size, 344 + get_rr_type_name(type)); 362 345 return addr; 363 346 } 364 347 ··· 368 347 unsigned long align, bool die_on_oom) 369 348 { 370 349 struct reserved_range *range = &physmem_info.reserved[type]; 371 - struct reserved_range *new_range; 350 + struct reserved_range *new_range = NULL; 372 351 unsigned int ranges_left; 373 352 unsigned long addr; 374 353 ··· 392 371 } 393 372 range->end = addr + size; 394 373 } 374 + if (type != RR_VMEM) { 375 + boot_debug("%-14s 0x%016lx-0x%016lx %-20s align 0x%lx split %d\n", "Alloc topdown:", 376 + addr, addr + size, get_rr_type_name(type), align, !!new_range); 377 + } 395 378 range->start = addr; 396 379 physmem_alloc_pos = addr; 397 380 physmem_alloc_ranges = ranges_left; ··· 411 386 unsigned long get_physmem_alloc_pos(void) 412 387 { 413 388 return physmem_alloc_pos; 389 + } 390 + 391 + void dump_physmem_reserved(void) 392 + { 393 + struct reserved_range *range; 394 + enum reserved_range_type t; 395 + unsigned long start, end; 396 + 397 + boot_debug("Reserved memory ranges:\n"); 398 + for_each_physmem_reserved_range(t, range, &start, &end) { 399 + if (end) { 400 + boot_debug("%-14s 0x%016lx-0x%016lx @%012lx chain %012lx\n", 401 + get_rr_type_name(t), start, end, (unsigned long)range, 402 + (unsigned long)range->chain); 403 + } 404 + } 414 405 }
+1
arch/s390/boot/startup.c
··· 525 525 __kaslr_offset, __kaslr_offset_phys); 526 526 kaslr_adjust_got(__kaslr_offset); 527 527 setup_vmem(__kaslr_offset, __kaslr_offset + kernel_size, asce_limit); 528 + dump_physmem_reserved(); 528 529 copy_bootdata(); 529 530 __apply_alternatives((struct alt_instr *)_vmlinux_info.alt_instructions, 530 531 (struct alt_instr *)_vmlinux_info.alt_instructions_end,
+2 -2
arch/s390/include/asm/physmem_info.h
··· 26 26 RR_AMODE31, 27 27 RR_IPLREPORT, 28 28 RR_CERT_COMP_LIST, 29 - RR_MEM_DETECT_EXTENDED, 29 + RR_MEM_DETECT_EXT, 30 30 RR_VMEM, 31 31 RR_MAX 32 32 }; ··· 128 128 RR_TYPE_NAME(AMODE31); 129 129 RR_TYPE_NAME(IPLREPORT); 130 130 RR_TYPE_NAME(CERT_COMP_LIST); 131 - RR_TYPE_NAME(MEM_DETECT_EXTENDED); 131 + RR_TYPE_NAME(MEM_DETECT_EXT); 132 132 RR_TYPE_NAME(VMEM); 133 133 default: 134 134 return "UNKNOWN";
+2 -2
arch/s390/kernel/setup.c
··· 702 702 { 703 703 unsigned long addr, size; 704 704 705 - if (get_physmem_reserved(RR_MEM_DETECT_EXTENDED, &addr, &size)) 705 + if (get_physmem_reserved(RR_MEM_DETECT_EXT, &addr, &size)) 706 706 memblock_reserve(addr, size); 707 707 } 708 708 ··· 710 710 { 711 711 unsigned long addr, size; 712 712 713 - if (get_physmem_reserved(RR_MEM_DETECT_EXTENDED, &addr, &size)) 713 + if (get_physmem_reserved(RR_MEM_DETECT_EXT, &addr, &size)) 714 714 memblock_phys_free(addr, size); 715 715 } 716 716