Questions about locking; turnstiles and sleeping threads

NGie Cooper yaneurabeya at gmail.com
Fri Nov 14 01:55:30 UTC 2014


On Thu, Nov 13, 2014 at 3:01 PM, Adrian Chadd <adrian at freebsd.org> wrote:
> 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.
>       */

- This should have WITNESS #ifdef guards (for clarity... it would
probably be optimized out by the compiler if -O0 wasn't specified, but
some folks seem to use -O0 lately, like np@).
- Should this have __predict_{false,true} applied to the if (safe) check?

Thanks!


More information about the freebsd-arch mailing list