Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern add some assertions to verify that CPU_INFO_FOREACH...



details:   https://anonhg.NetBSD.org/src/rev/379ed95b7829
branches:  trunk
changeset: 828470:379ed95b7829
user:      chs <chs%NetBSD.org@localhost>
date:      Fri Dec 15 16:05:51 2017 +0000

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

diffstat:

 sys/kern/init_main.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 591b079a0ec2 -r 379ed95b7829 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Fri Dec 15 16:03:29 2017 +0000
+++ b/sys/kern/init_main.c      Fri Dec 15 16:05:51 2017 +0000
@@ -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 @@
        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();



Home | Main Index | Thread Index | Old Index