git: fa290859fa63 - main - vm: Assert that pagesizes[] is sorted
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 04 Aug 2024 20:08:04 UTC
The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=fa290859fa63d65b5da3014038ae289c1b336700 commit fa290859fa63d65b5da3014038ae289c1b336700 Author: Alan Cox <alc@FreeBSD.org> AuthorDate: 2024-08-03 20:18:16 +0000 Commit: Alan Cox <alc@FreeBSD.org> CommitDate: 2024-08-04 19:53:15 +0000 vm: Assert that pagesizes[] is sorted Ensure that pmap_init() properly initialized pagesizes[]. In part, we are making this change to document the requirement that the non-zero elements of pagesizes[] must be in ascending order. Reviewed by: kib, markj --- sys/vm/vm_init.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index 0fd13f73a180..a0d3651ba266 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -100,6 +100,24 @@ long physmem; static void vm_mem_init(void *); SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL); +#ifdef INVARIANTS +/* + * Ensure that pmap_init() correctly initialized pagesizes[]. + */ +static void +vm_check_pagesizes(void) +{ + int i; + + KASSERT(pagesizes[0] == PAGE_SIZE, ("pagesizes[0] != PAGE_SIZE")); + for (i = 1; i < MAXPAGESIZES; i++) { + KASSERT((pagesizes[i - 1] != 0 && + pagesizes[i - 1] < pagesizes[i]) || pagesizes[i] == 0, + ("pagesizes[%d ... %d] are misconfigured", i - 1, i)); + } +} +#endif + /* * vm_mem_init() initializes the virtual memory system. * This is done only by the first cpu up. @@ -140,6 +158,10 @@ vm_mem_init(void *dummy) kmem_init_zero_region(); pmap_init(); vm_pager_init(); + +#ifdef INVARIANTS + vm_check_pagesizes(); +#endif } void