Questions about locking; turnstiles and sleeping threads

Adrian Chadd adrian at freebsd.org
Thu Nov 13 23:01:18 UTC 2014


I'd like to try and add WITNESS_WARN() where appropriate.

How's this look?

Index: kern_timeout.c
===================================================================
--- kern_timeout.c    (revision 274304)
+++ kern_timeout.c    (working copy)
@@ -1096,7 +1096,22 @@
     struct lock_class *class;
     int direct, sq_locked, use_lock;

+    /* XXX GIANTOK? c_lock can be NULL? */
+
     /*
+     * If safe is clear then we're not going to drop into the
+     * sleepq wait routines.  So, we don't have to check
+     * for the witness warning here.
+     *
+     * If safe is set then we may drop into the sleep routines
+     * so do the check.
+     */
+    if (safe) {
+        WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock,
+            "calling %s", __func__);
+    }
+
+    /*
      * Some old subsystems don't hold Giant while running a callout_stop(),
      * so just discard this check for the moment.
      */



-adrian


More information about the freebsd-arch mailing list