Module Name:    src
Committed By:   thorpej
Date:           Wed Apr 24 02:08:03 UTC 2024

Modified Files:
        src/sys/kern: subr_vmem.c

Log Message:
vmem_init(): Ensure that the quantum is a power of 2, and that if private
tags are being used, they are added to the arena before the first span is
added.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/subr_vmem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_vmem.c
diff -u src/sys/kern/subr_vmem.c:1.115 src/sys/kern/subr_vmem.c:1.116
--- src/sys/kern/subr_vmem.c:1.115	Sun Dec  3 19:34:08 2023
+++ src/sys/kern/subr_vmem.c	Wed Apr 24 02:08:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_vmem.c,v 1.115 2023/12/03 19:34:08 thorpej Exp $	*/
+/*	$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $	*/
 
 /*-
  * Copyright (c)2006,2007,2008,2009 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.115 2023/12/03 19:34:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_vmem.c,v 1.116 2024/04/24 02:08:03 thorpej Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_ddb.h"
@@ -971,6 +971,14 @@ vmem_init(vmem_t *vm, const char *name,
 	KASSERT((flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
 	KASSERT((~flags & (VM_SLEEP|VM_NOSLEEP)) != 0);
 	KASSERT(quantum > 0);
+	KASSERT(powerof2(quantum));
+
+	/*
+	 * If private tags are going to be used, they must
+	 * be added to the arena before the first span is
+	 * added.
+	 */
+	KASSERT((flags & VM_PRIVTAGS) == 0 || size == 0);
 
 #if defined(_KERNEL)
 	/* XXX: SMP, we get called early... */

Reply via email to