1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-27 11:55:06 +00:00

vm: Simplify startup page dumping conditional

This commit introduces the MINIDUMP_STARTUP_PAGE_TRACKING symbol and
uses it to simplify several instances of a complex preprocessor conditional
for adding pages allocated when bootstraping the kernel to minidumps.

Reviewed by:	markj, mhorne
Approved by:	markj (mentor)
Differential Revision: https://reviews.freebsd.org/D45085
This commit is contained in:
Bojan Novković 2024-05-03 19:53:56 +02:00
parent da76d349b6
commit 0a44b8a56d
8 changed files with 15 additions and 12 deletions

View File

@ -294,7 +294,8 @@
/*
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 1
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -200,5 +200,6 @@ extern vm_offset_t vm_max_kernel_address;
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 0
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -317,6 +317,7 @@ extern vm_offset_t dmap_max_addr;
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 1
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -246,5 +246,6 @@
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 0
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -308,11 +308,13 @@ extern int vm_level_0_order;
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 1
#else
/*
* No minidump with 32-bit powerpc.
*/
#define MINIDUMP_PAGE_TRACKING 0
#define MINIDUMP_STARTUP_PAGE_TRACKING 0
#endif
#define PMAP_HAS_DMAP (hw_direct_map)

View File

@ -257,5 +257,6 @@ extern vm_offset_t init_pt_va;
* Need a page dump array for minidump.
*/
#define MINIDUMP_PAGE_TRACKING 1
#define MINIDUMP_STARTUP_PAGE_TRACKING 1
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -1890,8 +1890,7 @@ startup_alloc(uma_zone_t zone, vm_size_t bytes, int domain, uint8_t *pflag,
pa = VM_PAGE_TO_PHYS(m);
for (i = 0; i < pages; i++, pa += PAGE_SIZE) {
#if defined(__aarch64__) || defined(__amd64__) || \
defined(__riscv) || defined(__powerpc64__)
#if MINIDUMP_PAGE_TRACKING && MINIDUMP_STARTUP_PAGE_TRACKING
if ((wait & M_NODUMP) == 0)
dump_add_page(pa);
#endif
@ -1918,8 +1917,7 @@ startup_free(void *mem, vm_size_t bytes)
if (va >= bootstart && va + bytes <= bootmem)
pmap_remove(kernel_pmap, va, va + bytes);
for (; bytes != 0; bytes -= PAGE_SIZE, m++) {
#if defined(__aarch64__) || defined(__amd64__) || \
defined(__riscv) || defined(__powerpc64__)
#if MINIDUMP_PAGE_TRACKING && MINIDUMP_STARTUP_PAGE_TRACKING
dump_drop_page(VM_PAGE_TO_PHYS(m));
#endif
vm_page_unwire_noq(m);

View File

@ -620,11 +620,7 @@ vm_page_startup(vm_offset_t vaddr)
vm_page_dump = (void *)(uintptr_t)pmap_map(&vaddr, new_end,
new_end + vm_page_dump_size, VM_PROT_READ | VM_PROT_WRITE);
bzero((void *)vm_page_dump, vm_page_dump_size);
#else
(void)last_pa;
#endif
#if defined(__aarch64__) || defined(__amd64__) || \
defined(__riscv) || defined(__powerpc64__)
#if MINIDUMP_STARTUP_PAGE_TRACKING
/*
* Include the UMA bootstrap pages, witness pages and vm_page_dump
* in a crash dump. When pmap_map() uses the direct map, they are
@ -632,6 +628,9 @@ vm_page_startup(vm_offset_t vaddr)
*/
for (pa = new_end; pa < end; pa += PAGE_SIZE)
dump_add_page(pa);
#endif
#else
(void)last_pa;
#endif
phys_avail[biggestone + 1] = new_end;
#ifdef __amd64__
@ -728,8 +727,7 @@ vm_page_startup(vm_offset_t vaddr)
*/
new_end = vm_reserv_startup(&vaddr, new_end);
#endif
#if defined(__aarch64__) || defined(__amd64__) || \
defined(__riscv) || defined(__powerpc64__)
#if MINIDUMP_PAGE_TRACKING && MINIDUMP_STARTUP_PAGE_TRACKING
/*
* Include vm_page_array and vm_reserv_array in a crash dump.
*/