Skip to content

Commit 9688b17

Browse files
Vasily GorbikAlexander Gordeev
authored andcommitted
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 <[email protected]> Acked-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent d2ebe06 commit 9688b17

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

arch/s390/boot/boot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ unsigned long physmem_alloc_range(enum reserved_range_type type, unsigned long s
5757
unsigned long align, unsigned long min, unsigned long max,
5858
bool die_on_oom);
5959
unsigned long get_physmem_alloc_pos(void);
60+
void dump_physmem_reserved(void);
6061
bool ipl_report_certs_intersects(unsigned long addr, unsigned long size,
6162
unsigned long *intersection_start);
6263
bool is_ipl_block_dump(void);

arch/s390/boot/physmem_info.c

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#define boot_fmt(fmt) "physmem: " fmt
23
#include <linux/processor.h>
34
#include <linux/errno.h>
45
#include <linux/init.h>
@@ -28,7 +29,7 @@ static struct physmem_range *__get_physmem_range_ptr(u32 n)
2829
return &physmem_info.online[n];
2930
if (unlikely(!physmem_info.online_extended)) {
3031
physmem_info.online_extended = (struct physmem_range *)physmem_alloc_range(
31-
RR_MEM_DETECT_EXTENDED, ENTRIES_EXTENDED_MAX, sizeof(long), 0,
32+
RR_MEM_DETECT_EXT, ENTRIES_EXTENDED_MAX, sizeof(long), 0,
3233
physmem_alloc_pos, true);
3334
}
3435
return &physmem_info.online_extended[n - MEM_INLINED_ENTRIES];
@@ -207,11 +208,16 @@ unsigned long detect_max_physmem_end(void)
207208
max_physmem_end = search_mem_end();
208209
physmem_info.info_source = MEM_DETECT_BIN_SEARCH;
209210
}
211+
boot_debug("Max physical memory: 0x%016lx (info source: %s)\n", max_physmem_end,
212+
get_physmem_info_source());
210213
return max_physmem_end;
211214
}
212215

213216
void detect_physmem_online_ranges(unsigned long max_physmem_end)
214217
{
218+
unsigned long start, end;
219+
int i;
220+
215221
if (!sclp_early_read_storage_info()) {
216222
physmem_info.info_source = MEM_DETECT_SCLP_STOR_INFO;
217223
} else if (physmem_info.info_source == MEM_DETECT_DIAG500_STOR_LIMIT) {
@@ -226,12 +232,16 @@ void detect_physmem_online_ranges(unsigned long max_physmem_end)
226232
} else if (max_physmem_end) {
227233
add_physmem_online_range(0, max_physmem_end);
228234
}
235+
boot_debug("Online memory ranges (info source: %s):\n", get_physmem_info_source());
236+
for_each_physmem_online_range(i, &start, &end)
237+
boot_debug(" online [%d]: 0x%016lx-0x%016lx\n", i, start, end);
229238
}
230239

231240
void physmem_set_usable_limit(unsigned long limit)
232241
{
233242
physmem_info.usable = limit;
234243
physmem_alloc_pos = limit;
244+
boot_debug("Usable memory limit: 0x%016lx\n", limit);
235245
}
236246

237247
static void die_oom(unsigned long size, unsigned long align, unsigned long min, unsigned long max)
@@ -265,14 +275,23 @@ static void die_oom(unsigned long size, unsigned long align, unsigned long min,
265275
disabled_wait();
266276
}
267277

268-
void physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size)
278+
static void _physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size)
269279
{
270280
physmem_info.reserved[type].start = addr;
271281
physmem_info.reserved[type].end = addr + size;
272282
}
273283

284+
void physmem_reserve(enum reserved_range_type type, unsigned long addr, unsigned long size)
285+
{
286+
_physmem_reserve(type, addr, size);
287+
boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Reserve:", addr, addr + size,
288+
get_rr_type_name(type));
289+
}
290+
274291
void physmem_free(enum reserved_range_type type)
275292
{
293+
boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Free:", physmem_info.reserved[type].start,
294+
physmem_info.reserved[type].end, get_rr_type_name(type));
276295
physmem_info.reserved[type].start = 0;
277296
physmem_info.reserved[type].end = 0;
278297
}
@@ -339,15 +358,17 @@ unsigned long physmem_alloc_range(enum reserved_range_type type, unsigned long s
339358
max = min(max, physmem_alloc_pos);
340359
addr = __physmem_alloc_range(size, align, min, max, 0, NULL, die_on_oom);
341360
if (addr)
342-
physmem_reserve(type, addr, size);
361+
_physmem_reserve(type, addr, size);
362+
boot_debug("%-14s 0x%016lx-0x%016lx %s\n", "Alloc range:", addr, addr + size,
363+
get_rr_type_name(type));
343364
return addr;
344365
}
345366

346367
unsigned long physmem_alloc(enum reserved_range_type type, unsigned long size,
347368
unsigned long align, bool die_on_oom)
348369
{
349370
struct reserved_range *range = &physmem_info.reserved[type];
350-
struct reserved_range *new_range;
371+
struct reserved_range *new_range = NULL;
351372
unsigned int ranges_left;
352373
unsigned long addr;
353374

@@ -371,6 +392,10 @@ unsigned long physmem_alloc(enum reserved_range_type type, unsigned long size,
371392
}
372393
range->end = addr + size;
373394
}
395+
if (type != RR_VMEM) {
396+
boot_debug("%-14s 0x%016lx-0x%016lx %-20s align 0x%lx split %d\n", "Alloc topdown:",
397+
addr, addr + size, get_rr_type_name(type), align, !!new_range);
398+
}
374399
range->start = addr;
375400
physmem_alloc_pos = addr;
376401
physmem_alloc_ranges = ranges_left;
@@ -387,3 +412,19 @@ unsigned long get_physmem_alloc_pos(void)
387412
{
388413
return physmem_alloc_pos;
389414
}
415+
416+
void dump_physmem_reserved(void)
417+
{
418+
struct reserved_range *range;
419+
enum reserved_range_type t;
420+
unsigned long start, end;
421+
422+
boot_debug("Reserved memory ranges:\n");
423+
for_each_physmem_reserved_range(t, range, &start, &end) {
424+
if (end) {
425+
boot_debug("%-14s 0x%016lx-0x%016lx @%012lx chain %012lx\n",
426+
get_rr_type_name(t), start, end, (unsigned long)range,
427+
(unsigned long)range->chain);
428+
}
429+
}
430+
}

arch/s390/boot/startup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ void startup_kernel(void)
525525
__kaslr_offset, __kaslr_offset_phys);
526526
kaslr_adjust_got(__kaslr_offset);
527527
setup_vmem(__kaslr_offset, __kaslr_offset + kernel_size, asce_limit);
528+
dump_physmem_reserved();
528529
copy_bootdata();
529530
__apply_alternatives((struct alt_instr *)_vmlinux_info.alt_instructions,
530531
(struct alt_instr *)_vmlinux_info.alt_instructions_end,

arch/s390/include/asm/physmem_info.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum reserved_range_type {
2626
RR_AMODE31,
2727
RR_IPLREPORT,
2828
RR_CERT_COMP_LIST,
29-
RR_MEM_DETECT_EXTENDED,
29+
RR_MEM_DETECT_EXT,
3030
RR_VMEM,
3131
RR_MAX
3232
};
@@ -128,7 +128,7 @@ static inline const char *get_rr_type_name(enum reserved_range_type t)
128128
RR_TYPE_NAME(AMODE31);
129129
RR_TYPE_NAME(IPLREPORT);
130130
RR_TYPE_NAME(CERT_COMP_LIST);
131-
RR_TYPE_NAME(MEM_DETECT_EXTENDED);
131+
RR_TYPE_NAME(MEM_DETECT_EXT);
132132
RR_TYPE_NAME(VMEM);
133133
default:
134134
return "UNKNOWN";

arch/s390/kernel/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,15 @@ static void __init reserve_physmem_info(void)
702702
{
703703
unsigned long addr, size;
704704

705-
if (get_physmem_reserved(RR_MEM_DETECT_EXTENDED, &addr, &size))
705+
if (get_physmem_reserved(RR_MEM_DETECT_EXT, &addr, &size))
706706
memblock_reserve(addr, size);
707707
}
708708

709709
static void __init free_physmem_info(void)
710710
{
711711
unsigned long addr, size;
712712

713-
if (get_physmem_reserved(RR_MEM_DETECT_EXTENDED, &addr, &size))
713+
if (get_physmem_reserved(RR_MEM_DETECT_EXT, &addr, &size))
714714
memblock_phys_free(addr, size);
715715
}
716716

0 commit comments

Comments
 (0)