Re: [patch 2/2] rtmutex: Avoid pointless requeueing in the deadlock detection chain walk

From: Steven Rostedt
Date: Thu May 15 2014 - 17:39:44 EST


On Wed, 14 May 2014 20:03:27 -0000
Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:

> /* Release the task */
> raw_spin_unlock_irqrestore(&task->pi_lock, flags);
> + /*
> + * We must abort the chain walk if there is no lock owner even
> + * in the dead lock detection case, as we have nothing to
> + * follow here.
> + */
> if (!rt_mutex_owner(lock)) {
> /*
> * If the requeue above changed the top waiter, then we need
> * to wake the new top waiter up to try to get the lock.
> */
> -
> if (top_waiter != rt_mutex_top_waiter(lock))
> wake_up_process(rt_mutex_top_waiter(lock)->task);

Seems we can change the above if condition to:

if (requeue && top_waiter != rt_mutex_top_waiter(lock))

as there was no "requeue above" that could change anything.

-- Steve


> raw_spin_unlock(&lock->wait_lock);
> @@ -404,18 +413,20 @@ static int rt_mutex_adjust_prio_chain(st
> get_task_struct(task);
> raw_spin_lock_irqsave(&task->pi_lock, flags);
>
> - if (waiter == rt_mutex_top_waiter(lock)) {
> - /* Boost the owner */
> - rt_mutex_dequeue_pi(task, top_waiter);
> - rt_mutex_enqueue_pi(task, waiter);
> - __rt_mutex_adjust_prio(task);
> -
> - } else if (top_waiter == waiter) {
> - /* Deboost the owner */
> - rt_mutex_dequeue_pi(task, waiter);
> - waiter = rt_mutex_top_waiter(lock);
> - rt_mutex_enqueue_pi(task, waiter);
> - __rt_mutex_adjust_prio(task);
> + if (requeue) {
> + if (waiter == rt_mutex_top_waiter(lock)) {
> + /* Boost the owner */
> + rt_mutex_dequeue_pi(task, top_waiter);
> + rt_mutex_enqueue_pi(task, waiter);
> + __rt_mutex_adjust_prio(task);
> +
> + } else if (top_waiter == waiter) {
> + /* Deboost the owner */
> + rt_mutex_dequeue_pi(task, waiter);
> + waiter = rt_mutex_top_waiter(lock);
> + rt_mutex_enqueue_pi(task, waiter);
> + __rt_mutex_adjust_prio(task);
> + }
> }
>
> raw_spin_unlock_irqrestore(&task->pi_lock, flags);
>

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