lkml.org 
[lkml]   [2010]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] rtmutex: ensure only the top waiter or higher priority task can take the lock and reduce unrelated boosting
From
Date
On Wed, 2010-12-15 at 16:09 +0800, Lai Jiangshan wrote:


> /*
> @@ -543,11 +491,13 @@ static void remove_waiter(struct rt_mutex *lock,
>
> raw_spin_lock_irqsave(&current->pi_lock, flags);
> plist_del(&waiter->list_entry, &lock->wait_list);
> - waiter->task = NULL;
> current->pi_blocked_on = NULL;
> raw_spin_unlock_irqrestore(&current->pi_lock, flags);
>
> - if (first && owner != current) {
> + if (!owner)
> + return;
> +
> + if (first) {

This is a bug. There's a small chance that the mutex timed out, and at
that same time, the owner gave up the lock and woke this task up. Which
means this task is the new owner of the lock iff it was the
rt_mutex_top_waiter().

The fix is to do this:


if (!owner) {
if (first) {
ret = try_to_take_rt_mutex();
BUG_ON(!ret);
}
return first;
}

if (first) {

We need to make remove_waiter return 1 if it took the lock and 0 if it
did not, so it can pass this information back to the caller.

if (unlikely(ret)) {
if (remove_waiter(...))
ret = 0;
}

-- Steve




\
 
 \ /
  Last update: 2010-12-15 22:55    [W:0.582 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site