Re: [PATCH/RFC] Futex mmap_sem deadlock

Olof Johansson
2005-02-23T16:26:32Z

On Wed, Feb 23, 2005 at 11:39:08AM +0000, David Howells wrote:
> Alternately, you could just have do_page_fault() do:
>
> while (!down_read_trylock(&current->mm->mmap_sem))
> continue;
>
> However, note that this can suffer from starvation due to a never ending flow
> of mixed write-locks and read-locks on other CPUs. Unlikely, true, but not
> impossible.

How can this help?

The semaphore is held for reading by the thread that faulted in
futex_wait() -> get_user(), so no writers will be let through. Until the
writer has been let through, the down_read_trylock will never succeed
either. No forward progress can be made even with the above loop.

-Olof