kernel - Fixup for UP build
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 31 Aug 2010 06:24:42 +0000 (23:24 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 31 Aug 2010 06:24:42 +0000 (23:24 -0700)
* Conditionalize td_mpcount accesses for SMP only

sys/kern/kern_intr.c
sys/kern/tty_cons.c

index ac43f89..dd0b74f 100644 (file)
@@ -80,35 +80,58 @@ int max_installed_soft_intr;
 
 #define EMERGENCY_INTR_POLLING_FREQ_MAX 20000
 
+/*
+ * Assert that callers into interrupt handlers don't return with
+ * dangling tokens, spinlocks, or mp locks.
+ */
 #ifdef INVARIANTS
 
+#ifdef SMP
+
+#define SMP_INVARIANTS_DECLARE \
+       int mpcount;
+
+#define SMP_INVARIANTS_GET(td)         \
+       mpcount = (td)->td_mpcount
+
+#define SMP_INVARIANTS_TEST(td, name)                                  \
+               KASSERT(mpcount == (td)->td_mpcount,                    \
+                       ("mpcount mismatch after interrupt handler %s", \
+                       name))
+
+#define SMP_INVARIANTS_ADJMP(count)    mpcount += (count)
+
+#else
+
+#define SMP_INVARIANTS_DECLARE
+#define SMP_INVARIANTS_GET(td)
+#define SMP_INVARIANTS_TEST(td, name)
+
+#endif
+
 #define TD_INVARIANTS_DECLARE  \
-       int mpcount;            \
+       SMP_INVARIANTS_DECLARE  \
        int spincount;          \
        lwkt_tokref_t curstop
 
 #define TD_INVARIANTS_GET(td)                                  \
        do {                                                    \
-               mpcount = (td)->td_mpcount;                     \
+               SMP_INVARIANTS_GET(td);                         \
                spincount = (td)->td_gd->gd_spinlocks_wr;       \
                curstop = (td)->td_toks_stop;                   \
        } while(0)
 
 #define TD_INVARIANTS_TEST(td, name)                                   \
        do {                                                            \
-               KASSERT(mpcount == (td)->td_mpcount,                    \
-                       ("mpcount mismatch after interrupt handler %s", \
-                       name));                                         \
                KASSERT(spincount == (td)->td_gd->gd_spinlocks_wr,      \
                        ("spincount mismatch after interrupt handler %s", \
                        name));                                         \
                KASSERT(curstop == (td)->td_toks_stop,                  \
                        ("token count mismatch after interrupt handler %s", \
                        name));                                         \
+               SMP_INVARIANTS_TEST(td, name);                          \
        } while(0)
 
-#define TD_INVARIANTS_ADJMP(count)     mpcount += (count)
-
 #else
 
 #define TD_INVARIANTS_DECLARE
@@ -706,7 +729,7 @@ ithread_fast_handler(struct intrframe *frame)
                    break;
                }
                got_mplock = 1;
-               TD_INVARIANTS_ADJMP(1);
+               SMP_INVARIANTS_ADJMP(1);
            }
 #endif
            if (rec->serializer) {
index eb60c7b..409fc2e 100644 (file)
@@ -187,7 +187,9 @@ done:
         * the SMP/AP boot will blow up on us.
         */
        lwkt_reltoken(&tty_token);
+#ifdef SMP
        KKASSERT(curthread->td_mpcount == 1);
+#endif
 }