Re: PI BUG with -rt13

david singleton
2005-11-18T17:05:27Z

On Nov 18, 2005, at 5:27 AM, Ingo Molnar wrote:

>
> * Dinakar Guniguntala <dino@in.ibm.com> wrote:
>
>> Ingo, Thanks for providing the fix. However I still hit the same bug
>> even with your changes
>
> even with my patch the robust-futex code is still quite broken. E.g. in
> down_futex(), it accesses rt-mutex internals without any locking (!):
>
> if (rt_mutex_free(lock)) {
> __down_mutex(lock __EIP__);
> rt_mutex_set_owner(lock, owner_task->thread_info);
> }
>
> both rt_mutex_free() and rt_mutex_set_owner() must be called with the
> proper locking. David?

Yes, the lock needs to be protected by the robust semaphore.
The locking order is:

mmap_sem to protect the vma that holds the pthread_mutex

robust_sem to protect the futex_mutex chain.

futex_mutex - the rt_mutex associated with the
pthread_mutex.

This section of code performs the locking of the first waiter
on the pthread_mutex, which was locked by another thread in the
fast path in userspace. The fast path locking does not enter
the
kernel.

The first waiter locks the futex_mutex and then changes the
owner to the 'owning' thread. The waiter then calls
down_interruptible
to block on the futex_mutex.

I'll provide a patch to protect this piece of code.

David

>
> Ingo