Put last_td accessing back into INVARIANTS
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 28 Dec 2008 03:24:30 +0000 (11:24 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 28 Dec 2008 03:45:38 +0000 (11:45 +0800)
sys/kern/lwkt_serialize.c
sys/sys/serialize.h

index f63e1bb..7b972e3 100644 (file)
@@ -122,8 +122,9 @@ void
 lwkt_serialize_init(lwkt_serialize_t s)
 {
     atomic_intr_init(&s->interlock);
+#ifdef INVARIANTS
     s->last_td = (void *)-4;
-
+#endif
     s->sleep_cnt = 0;
     s->tryfail_cnt = 0;
     s->enter_cnt = 0;
@@ -145,8 +146,9 @@ lwkt_serialize_adaptive_enter(lwkt_serialize_t s)
     logslz(enter_beg, s);
     atomic_intr_cond_enter(&s->interlock, lwkt_serialize_adaptive_sleep, &bo);
     logslz(enter_end, s);
-
+#ifdef INVARIANTS
     s->last_td = curthread;
+#endif
 #ifdef PROFILE_SERIALIZER
     s->enter_cnt++;
 #endif
@@ -161,8 +163,9 @@ lwkt_serialize_enter(lwkt_serialize_t s)
     logslz(enter_beg, s);
     atomic_intr_cond_enter(&s->interlock, lwkt_serialize_sleep, s);
     logslz(enter_end, s);
-
+#ifdef INVARIANTS
     s->last_td = curthread;
+#endif
 #ifdef PROFILE_SERIALIZER
     s->enter_cnt++;
 #endif
@@ -183,7 +186,9 @@ lwkt_serialize_try(lwkt_serialize_t s)
 #endif
     logslz(try, s);
     if ((error = atomic_intr_cond_try(&s->interlock)) == 0) {
+#ifdef INVARIANTS
        s->last_td = curthread;
+#endif
        logslz(tryok, s);
        return(1);
     }
@@ -198,8 +203,9 @@ void
 lwkt_serialize_exit(lwkt_serialize_t s)
 {
     ASSERT_SERIALIZED(s);
+#ifdef INVARIANTS
     s->last_td = (void *)-2;
-
+#endif
     logslz(exit_beg, s);
     atomic_intr_cond_exit(&s->interlock, lwkt_serialize_wakeup, s);
     logslz(exit_end, s);
@@ -233,8 +239,9 @@ lwkt_serialize_handler_call(lwkt_serialize_t s, void (*func)(void *, void *),
        logslz(enter_beg, s);
        atomic_intr_cond_enter(&s->interlock, lwkt_serialize_sleep, s);
        logslz(enter_end, s);
-
+#ifdef INVARIANTS
        s->last_td = curthread;
+#endif
 #ifdef PROFILE_SERIALIZER
        s->enter_cnt++;
 #endif
@@ -242,8 +249,9 @@ lwkt_serialize_handler_call(lwkt_serialize_t s, void (*func)(void *, void *),
            func(arg, frame);
 
        ASSERT_SERIALIZED(s);
+#ifdef INVARIANTS
        s->last_td = (void *)-2;
-
+#endif
        logslz(exit_beg, s);
        atomic_intr_cond_exit(&s->interlock, lwkt_serialize_wakeup, s);
        logslz(exit_end, s);
@@ -268,14 +276,17 @@ lwkt_serialize_handler_try(lwkt_serialize_t s, void (*func)(void *, void *),
 #endif
        logslz(try, s);
        if (atomic_intr_cond_try(&s->interlock) == 0) {
+#ifdef INVARIANTS
            s->last_td = curthread;
+#endif
            logslz(tryok, s);
 
            func(arg, frame);
 
            ASSERT_SERIALIZED(s);
+#ifdef INVARIANTS
            s->last_td = (void *)-2;
-
+#endif
            logslz(exit_beg, s);
            atomic_intr_cond_exit(&s->interlock, lwkt_serialize_wakeup, s);
            logslz(exit_end, s);
index b54ba10..88c0dc2 100644 (file)
@@ -29,10 +29,18 @@ struct lwkt_serialize {
     unsigned int       try_cnt;
 };
 
+#ifdef INVARIANTS
+
+/*
+ * Note that last_td is only maintained when INVARIANTS is turned on,
+ * so this check is only useful as part of a [K]KASSERT.
+ */
 #define IS_SERIALIZED(ss)              ((ss)->last_td == curthread)
 #define ASSERT_SERIALIZED(ss)          KKASSERT(IS_SERIALIZED((ss)))
 #define ASSERT_NOT_SERIALIZED(ss)      KKASSERT(!IS_SERIALIZED((ss)))
 
+#endif /* INVARIANTS */
+
 typedef struct lwkt_serialize *lwkt_serialize_t;
 
 void lwkt_serialize_init(lwkt_serialize_t);