Re: Documentation/vm/locking: why not hold two PT locks?

Robert Love
2004-02-08T21:29:38Z

On Sun, 2004-02-08 at 16:18 -0500, Ed L Cashin wrote:

> Hi. Documentation/vm/locking says one must not simultaneously hold
> the page table lock on mm A and mm B. Is that true? Where is the
> danger?

There isn't a proscribed lock ordering hierarchy, so you can deadlock.

Assume thread 1 obtains the lock on mm A.

Assume thread 2 obtains the lock on mm B.

Assume thread 1 now obtains the lock on mm B - it is taken, so spin
waiting.

Assume thread 2 now obtains the lock on mm A - it too is taken, so spin
waiting.

Boom..

Robert Love