Module Name:    src
Committed By:   chs
Date:           Fri Dec 15 16:05:51 UTC 2017

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

Log Message:
add some assertions to verify that CPU_INFO_FOREACH() works right
early in the boot process.  this detects existing bugs on some platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.492 -r1.493 src/sys/kern/init_main.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/init_main.c
diff -u src/sys/kern/init_main.c:1.492 src/sys/kern/init_main.c:1.493
--- src/sys/kern/init_main.c:1.492	Fri Oct 27 12:25:15 2017
+++ src/sys/kern/init_main.c	Fri Dec 15 16:05:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: init_main.c,v 1.492 2017/10/27 12:25:15 joerg Exp $	*/
+/*	$NetBSD: init_main.c,v 1.493 2017/12/15 16:05:51 chs Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.492 2017/10/27 12:25:15 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.493 2017/12/15 16:05:51 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -266,6 +266,19 @@ main(void)
 	CPU_INFO_ITERATOR cii;
 	struct cpu_info *ci;
 
+#ifdef DIAGNOSTIC
+	/*
+	 * Verify that CPU_INFO_FOREACH() knows about the boot CPU
+	 * and only the boot CPU at this point.
+	 */
+	int cpucount = 0;
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		KASSERT(ci == curcpu());
+		cpucount++;
+	}
+	KASSERT(cpucount == 1);
+#endif
+
 	l = &lwp0;
 #ifndef LWP0_CPU_INFO
 	l->l_cpu = curcpu();

Reply via email to