vm: Fix kstack alignment assertion

The expectation that the allocation will be aligned to the kstack size
only applies when allocating from a kstack arena, not when allocating a
non-standard size from the kernel arena.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Fixes:		7a79d06697 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
Reviewed by:	bnovkov, siderop1_netapp.com
Differential Revision:	https://reviews.freebsd.org/D54171
This commit is contained in:
Dag-Erling Smørgrav
2025-12-11 10:01:47 +01:00
parent e3fa0a22dd
commit a35545ee02
+6 -4
View File
@@ -321,10 +321,12 @@ vm_thread_alloc_kstack_kva(vm_size_t size, int domain)
rv = vmem_alloc(arena, size, M_BESTFIT | M_NOWAIT, &addr);
if (rv == ENOMEM)
return (0);
KASSERT(atop(addr - VM_MIN_KERNEL_ADDRESS) %
(kstack_pages + KSTACK_GUARD_PAGES) == 0,
("%s: allocated kstack KVA not aligned to multiple of kstack size",
__func__));
if (size == ptoa(kstack_pages + KSTACK_GUARD_PAGES)) {
/* This expectation only applies to kstack arenas */
KASSERT((addr - VM_MIN_KERNEL_ADDRESS) % size == 0,
("%s: allocated kstack KVA not aligned to multiple of kstack size",
__func__));
}
return (addr);
#else