Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Dec 2025 18:05:56 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3ed0824b743a - stable/15 - vm: Fix kstack alignment assertion
Message-ID:  <69459404.235bc.7cee7ea5@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by des:

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

commit 3ed0824b743af50a60402070c94f23591c75162f
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-12-11 09:01:47 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-12-19 18:05:43 +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
    
    (cherry picked from commit a35545ee02680cee04c354b50182dd94d4489666)
---
 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


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69459404.235bc.7cee7ea5>