The branch main has been updated by des:

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

commit a35545ee02680cee04c354b50182dd94d4489666
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2025-12-11 09:01:47 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2025-12-11 09:02:07 +0000

    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:          7a79d0669761 ("vm: improve kstack_object pindex calculation 
to avoid pindex holes")
    Reviewed by:    bnovkov, siderop1_netapp.com
    Differential Revision:  https://reviews.freebsd.org/D54171
---
 sys/vm/vm_glue.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 18d789c59281..925bb92cdd75 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -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

Reply via email to