Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 May 2024 17:25:13 GMT
From:      Bojan =?utf-8?Q?Novkovi=C4=87?= <bnovkov@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 0a44b8a56d23 - main - vm: Simplify startup page dumping conditional
Message-ID:  <202405251725.44PHPD4f026692@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bnovkov:

URL: https://cgit.FreeBSD.org/src/commit/?id=0a44b8a56d23e24b05471ddb038b7dd30b149efe

commit 0a44b8a56d23e24b05471ddb038b7dd30b149efe
Author:     Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2024-05-03 17:53:56 +0000
Commit:     Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2024-05-25 17:24:55 +0000

    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
---
 sys/amd64/include/vmparam.h   |  3 ++-
 sys/arm/include/vmparam.h     |  1 +
 sys/arm64/include/vmparam.h   |  1 +
 sys/i386/include/vmparam.h    |  1 +
 sys/powerpc/include/vmparam.h |  2 ++
 sys/riscv/include/vmparam.h   |  1 +
 sys/vm/uma_core.c             |  6 ++----
 sys/vm/vm_page.c              | 12 +++++-------
 8 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h
index e5155a7c7d47..93c2648e8fac 100644
--- a/sys/amd64/include/vmparam.h
+++ b/sys/amd64/include/vmparam.h
@@ -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_ */
 
diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h
index 4ad42cfbe16b..15807923cefb 100644
--- a/sys/arm/include/vmparam.h
+++ b/sys/arm/include/vmparam.h
@@ -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_ */
diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h
index 0dcd02d63938..0e93e4026d4a 100644
--- a/sys/arm64/include/vmparam.h
+++ b/sys/arm64/include/vmparam.h
@@ -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_ */
 
diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h
index 0d9734ae3830..6f8885a539c3 100644
--- a/sys/i386/include/vmparam.h
+++ b/sys/i386/include/vmparam.h
@@ -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_ */
diff --git a/sys/powerpc/include/vmparam.h b/sys/powerpc/include/vmparam.h
index 250da8298610..a612acbef239 100644
--- a/sys/powerpc/include/vmparam.h
+++ b/sys/powerpc/include/vmparam.h
@@ -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)
diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h
index 5711bc8c347e..5092977d0669 100644
--- a/sys/riscv/include/vmparam.h
+++ b/sys/riscv/include/vmparam.h
@@ -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_ */
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index f9b6e18899c6..59066eb96ae9 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -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);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 4429ec067673..9ba31cb9e1b3 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -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.
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405251725.44PHPD4f026692>