Questions about locking; turnstiles and sleeping threads

Adrian Chadd adrian at freebsd.org
Thu Nov 13 17:31:41 UTC 2014


On 13 November 2014 02:14, Alfred Perlstein <alfred at freebsd.org> wrote:
> Would need more context to help on this.
>
> I can't tell based on your description which thread is holding which lock.
>
> If A is waiting for callout C to stop AND there exists a thread B that is
> contending against C for a lock, you should be fine so long as there is no
> lock cycle against A.
>
> Would be best if you pointed at some code and gave descriptions.

I haven't dug into the USB side of things ,but on the atheros side I
gave the description above.

Thread A grabs lock X and tries to drain callout, which involves
grabbing lock Y to do the dirty work. Lock Y isn't held at this point
- the callout is about to run or is running, so it enters the sleepq
call to finish the drain.

Thread B wants to grab lock X, but can't because thread A holds lock X
and is in a sleepq due to callout_drain(). Hence panic.

I'll poke people on IRC today and see if I can get a better
description of what/where the WITNESS_WARN() should be placed in
callout_drain(). Then we'll see what's left triggering it.




-adrian


More information about the freebsd-arch mailing list