Re: recursive spinlocks. Shoot.

Nick Piggin (piggin@cyberone.com.au)
Thu, 22 May 2003 15:09:56 +1000


On Thu, May 22, 2003 at 06:42:15AM +0200, Peter T. Breuer wrote:
> "Nick Piggin wrote:"
> > Locking is an implementation issue, and as such I think you'll have
> > to come up with a real problem or some real code. You must have some
> > target problem in mind?
>
> I'll butt back in here.
>
snip

>
> The result was a call from the block driver to the md driver with a
> lock held, and a rather unexpected call back from the md driver that
> impotently tried to take the same lock.
>
> Same thread.
>

OK, in this case, it didn't sound like your block driver
expected to be re-entered. Lucky the problem immediately
caused a deadlock ;)

More seriously, lets say you get around the above with
recursive locks:

Thread 1 Thread 2 (on another cpu)
enter the block driver
take the bd lock
issue an md ioctl
take the md lock
enter the block driver
spin on bd lock
automatically call md ioctl
spin on md lock

So the problem needs a rethink.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/