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

2014-05-30 Thread Steven Rostedt
On Wed, 28 May 2014 11:43:16 +0200 (CEST)
Thomas Gleixner  wrote:

[snip]

> > 
> > In the above case, could we go 1 step further and avoid taking the pi
> > lock as well?

[snip]

> 
> Indeed.
> 
>  

Are you going to repost this patch? I'd like to review that one instead
of this one if you're going to make such a charge.


Thanks,

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


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

2014-05-30 Thread Steven Rostedt
On Wed, 28 May 2014 11:43:16 +0200 (CEST)
Thomas Gleixner t...@linutronix.de wrote:

[snip]

  
  In the above case, could we go 1 step further and avoid taking the pi
  lock as well?

[snip]

 
 Indeed.
 
  

Are you going to repost this patch? I'd like to review that one instead
of this one if you're going to make such a charge.


Thanks,

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


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

2014-05-28 Thread Thomas Gleixner
On Tue, 27 May 2014, Jason Low wrote:
> On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner  wrote:
> 
> > @@ -440,32 +452,41 @@ static int rt_mutex_adjust_prio_chain(st
> > get_task_struct(task);
> > raw_spin_lock_irqsave(>pi_lock, flags);
> >
> > -   if (waiter == rt_mutex_top_waiter(lock)) {
> > -   /*
> > -* The waiter became the top waiter on the
> > -* lock. Remove the previous top waiter from the tasks
> > -* pi waiters list and add waiter to it.
> > -*/
> > -   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> > -   rt_mutex_enqueue_pi(task, waiter);
> > -   __rt_mutex_adjust_prio(task);
> > -
> > -   } else if (prerequeue_top_waiter == waiter) {
> > -   /*
> > -* The waiter was the top waiter on the lock. Remove
> > -* waiter from the tasks pi waiters list and add the
> > -* new top waiter to it.
> > -*/
> > -   rt_mutex_dequeue_pi(task, waiter);
> > -   waiter = rt_mutex_top_waiter(lock);
> > -   rt_mutex_enqueue_pi(task, waiter);
> > -   __rt_mutex_adjust_prio(task);
> > -
> > -   } else {
> > -   /*
> > -* Nothing changed. No need to do any priority
> > -* adjustment.
> > -*/
> > +   /*
> > +* In case we are just following the lock chain for deadlock
> > +* detection we can avoid the whole requeue and priority
> > +* adjustment business.
> > +*/
> > +   if (requeue) {
> > +   if (waiter == rt_mutex_top_waiter(lock)) {
> > +   /*
> > +* The waiter became the top waiter on the
> > +* lock. Remove the previous top waiter from
> > +* the tasks pi waiters list and add waiter to
> > +* it.
> > +*/
> > +   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> > +   rt_mutex_enqueue_pi(task, waiter);
> > +   __rt_mutex_adjust_prio(task);
> > +
> > +   } else if (prerequeue_top_waiter == waiter) {
> > +   /*
> > +* The waiter was the top waiter on the
> > +* lock. Remove waiter from the tasks pi
> > +* waiters list and add the new top waiter to
> > +* it.
> > +*/
> > +   rt_mutex_dequeue_pi(task, waiter);
> > +   waiter = rt_mutex_top_waiter(lock);
> > +   rt_mutex_enqueue_pi(task, waiter);
> > +   __rt_mutex_adjust_prio(task);
> > +
> > +   } else {
> > +   /*
> > +* Nothing changed. No need to do any priority
> > +* adjustment.
> > +*/
> > +   }
> > }
> >
> > raw_spin_unlock_irqrestore(>pi_lock, flags);
> 
> In the above case, could we go 1 step further and avoid taking the pi
> lock as well?
> 
> if (requeue) {
> raw_spin_lock_irqsave(>pi_lock, flags);
> 
> if (waiter == rt_mutex_top_waiter(lock)) {
> /*
>  * The waiter became the top waiter on the
>  * lock. Remove the previous top waiter from
>  * the tasks pi waiters list and add waiter to
>  * it.
>  */
> rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> rt_mutex_enqueue_pi(task, waiter);
> __rt_mutex_adjust_prio(task);
> 
> } else if (prerequeue_top_waiter == waiter) {
> /*
>  * The waiter was the top waiter on the
>  * lock. Remove waiter from the tasks pi
>  * waiters list and add the new top waiter to
>  * it.
>  */
> rt_mutex_dequeue_pi(task, waiter);
> waiter = rt_mutex_top_waiter(lock);
> rt_mutex_enqueue_pi(task, waiter);
> __rt_mutex_adjust_prio(task);
> 
> } else {
> /*
>  * Nothing changed. No need to do any priority
>  * adjustment.
>  */
> }
> 
> raw_spin_unlock_irqrestore(>pi_lock, flags);
> }

Indeed.

 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

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

2014-05-28 Thread Thomas Gleixner
On Tue, 27 May 2014, Jason Low wrote:
 On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner t...@linutronix.de wrote:
 
  @@ -440,32 +452,41 @@ 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)) {
  -   /*
  -* The waiter became the top waiter on the
  -* lock. Remove the previous top waiter from the tasks
  -* pi waiters list and add waiter to it.
  -*/
  -   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
  -   rt_mutex_enqueue_pi(task, waiter);
  -   __rt_mutex_adjust_prio(task);
  -
  -   } else if (prerequeue_top_waiter == waiter) {
  -   /*
  -* The waiter was the top waiter on the lock. Remove
  -* waiter from the tasks pi waiters list and add the
  -* new top waiter to it.
  -*/
  -   rt_mutex_dequeue_pi(task, waiter);
  -   waiter = rt_mutex_top_waiter(lock);
  -   rt_mutex_enqueue_pi(task, waiter);
  -   __rt_mutex_adjust_prio(task);
  -
  -   } else {
  -   /*
  -* Nothing changed. No need to do any priority
  -* adjustment.
  -*/
  +   /*
  +* In case we are just following the lock chain for deadlock
  +* detection we can avoid the whole requeue and priority
  +* adjustment business.
  +*/
  +   if (requeue) {
  +   if (waiter == rt_mutex_top_waiter(lock)) {
  +   /*
  +* The waiter became the top waiter on the
  +* lock. Remove the previous top waiter from
  +* the tasks pi waiters list and add waiter to
  +* it.
  +*/
  +   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
  +   rt_mutex_enqueue_pi(task, waiter);
  +   __rt_mutex_adjust_prio(task);
  +
  +   } else if (prerequeue_top_waiter == waiter) {
  +   /*
  +* The waiter was the top waiter on the
  +* lock. Remove waiter from the tasks pi
  +* waiters list and add the new top waiter to
  +* it.
  +*/
  +   rt_mutex_dequeue_pi(task, waiter);
  +   waiter = rt_mutex_top_waiter(lock);
  +   rt_mutex_enqueue_pi(task, waiter);
  +   __rt_mutex_adjust_prio(task);
  +
  +   } else {
  +   /*
  +* Nothing changed. No need to do any priority
  +* adjustment.
  +*/
  +   }
  }
 
  raw_spin_unlock_irqrestore(task-pi_lock, flags);
 
 In the above case, could we go 1 step further and avoid taking the pi
 lock as well?
 
 if (requeue) {
 raw_spin_lock_irqsave(task-pi_lock, flags);
 
 if (waiter == rt_mutex_top_waiter(lock)) {
 /*
  * The waiter became the top waiter on the
  * lock. Remove the previous top waiter from
  * the tasks pi waiters list and add waiter to
  * it.
  */
 rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
 rt_mutex_enqueue_pi(task, waiter);
 __rt_mutex_adjust_prio(task);
 
 } else if (prerequeue_top_waiter == waiter) {
 /*
  * The waiter was the top waiter on the
  * lock. Remove waiter from the tasks pi
  * waiters list and add the new top waiter to
  * it.
  */
 rt_mutex_dequeue_pi(task, waiter);
 waiter = rt_mutex_top_waiter(lock);
 rt_mutex_enqueue_pi(task, waiter);
 __rt_mutex_adjust_prio(task);
 
 } else {
 /*
  * Nothing changed. No need to do any priority
  * adjustment.
  */
 }
 
 raw_spin_unlock_irqrestore(task-pi_lock, flags);
 }

Indeed.

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


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

2014-05-27 Thread Jason Low
On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner  wrote:

> @@ -440,32 +452,41 @@ static int rt_mutex_adjust_prio_chain(st
> get_task_struct(task);
> raw_spin_lock_irqsave(>pi_lock, flags);
>
> -   if (waiter == rt_mutex_top_waiter(lock)) {
> -   /*
> -* The waiter became the top waiter on the
> -* lock. Remove the previous top waiter from the tasks
> -* pi waiters list and add waiter to it.
> -*/
> -   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> -   rt_mutex_enqueue_pi(task, waiter);
> -   __rt_mutex_adjust_prio(task);
> -
> -   } else if (prerequeue_top_waiter == waiter) {
> -   /*
> -* The waiter was the top waiter on the lock. Remove
> -* waiter from the tasks pi waiters list and add the
> -* new top waiter to it.
> -*/
> -   rt_mutex_dequeue_pi(task, waiter);
> -   waiter = rt_mutex_top_waiter(lock);
> -   rt_mutex_enqueue_pi(task, waiter);
> -   __rt_mutex_adjust_prio(task);
> -
> -   } else {
> -   /*
> -* Nothing changed. No need to do any priority
> -* adjustment.
> -*/
> +   /*
> +* In case we are just following the lock chain for deadlock
> +* detection we can avoid the whole requeue and priority
> +* adjustment business.
> +*/
> +   if (requeue) {
> +   if (waiter == rt_mutex_top_waiter(lock)) {
> +   /*
> +* The waiter became the top waiter on the
> +* lock. Remove the previous top waiter from
> +* the tasks pi waiters list and add waiter to
> +* it.
> +*/
> +   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
> +   rt_mutex_enqueue_pi(task, waiter);
> +   __rt_mutex_adjust_prio(task);
> +
> +   } else if (prerequeue_top_waiter == waiter) {
> +   /*
> +* The waiter was the top waiter on the
> +* lock. Remove waiter from the tasks pi
> +* waiters list and add the new top waiter to
> +* it.
> +*/
> +   rt_mutex_dequeue_pi(task, waiter);
> +   waiter = rt_mutex_top_waiter(lock);
> +   rt_mutex_enqueue_pi(task, waiter);
> +   __rt_mutex_adjust_prio(task);
> +
> +   } else {
> +   /*
> +* Nothing changed. No need to do any priority
> +* adjustment.
> +*/
> +   }
> }
>
> raw_spin_unlock_irqrestore(>pi_lock, flags);

In the above case, could we go 1 step further and avoid taking the pi
lock as well?

if (requeue) {
raw_spin_lock_irqsave(>pi_lock, flags);

if (waiter == rt_mutex_top_waiter(lock)) {
/*
 * The waiter became the top waiter on the
 * lock. Remove the previous top waiter from
 * the tasks pi waiters list and add waiter to
 * it.
 */
rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
rt_mutex_enqueue_pi(task, waiter);
__rt_mutex_adjust_prio(task);

} else if (prerequeue_top_waiter == waiter) {
/*
 * The waiter was the top waiter on the
 * lock. Remove waiter from the tasks pi
 * waiters list and add the new top waiter to
 * it.
 */
rt_mutex_dequeue_pi(task, waiter);
waiter = rt_mutex_top_waiter(lock);
rt_mutex_enqueue_pi(task, waiter);
__rt_mutex_adjust_prio(task);

} else {
/*
 * Nothing changed. No need to do any priority
 * adjustment.
 */
}

raw_spin_unlock_irqrestore(>pi_lock, flags);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2014-05-27 Thread Jason Low
On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner t...@linutronix.de wrote:

 @@ -440,32 +452,41 @@ 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)) {
 -   /*
 -* The waiter became the top waiter on the
 -* lock. Remove the previous top waiter from the tasks
 -* pi waiters list and add waiter to it.
 -*/
 -   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
 -   rt_mutex_enqueue_pi(task, waiter);
 -   __rt_mutex_adjust_prio(task);
 -
 -   } else if (prerequeue_top_waiter == waiter) {
 -   /*
 -* The waiter was the top waiter on the lock. Remove
 -* waiter from the tasks pi waiters list and add the
 -* new top waiter to it.
 -*/
 -   rt_mutex_dequeue_pi(task, waiter);
 -   waiter = rt_mutex_top_waiter(lock);
 -   rt_mutex_enqueue_pi(task, waiter);
 -   __rt_mutex_adjust_prio(task);
 -
 -   } else {
 -   /*
 -* Nothing changed. No need to do any priority
 -* adjustment.
 -*/
 +   /*
 +* In case we are just following the lock chain for deadlock
 +* detection we can avoid the whole requeue and priority
 +* adjustment business.
 +*/
 +   if (requeue) {
 +   if (waiter == rt_mutex_top_waiter(lock)) {
 +   /*
 +* The waiter became the top waiter on the
 +* lock. Remove the previous top waiter from
 +* the tasks pi waiters list and add waiter to
 +* it.
 +*/
 +   rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
 +   rt_mutex_enqueue_pi(task, waiter);
 +   __rt_mutex_adjust_prio(task);
 +
 +   } else if (prerequeue_top_waiter == waiter) {
 +   /*
 +* The waiter was the top waiter on the
 +* lock. Remove waiter from the tasks pi
 +* waiters list and add the new top waiter to
 +* it.
 +*/
 +   rt_mutex_dequeue_pi(task, waiter);
 +   waiter = rt_mutex_top_waiter(lock);
 +   rt_mutex_enqueue_pi(task, waiter);
 +   __rt_mutex_adjust_prio(task);
 +
 +   } else {
 +   /*
 +* Nothing changed. No need to do any priority
 +* adjustment.
 +*/
 +   }
 }

 raw_spin_unlock_irqrestore(task-pi_lock, flags);

In the above case, could we go 1 step further and avoid taking the pi
lock as well?

if (requeue) {
raw_spin_lock_irqsave(task-pi_lock, flags);

if (waiter == rt_mutex_top_waiter(lock)) {
/*
 * The waiter became the top waiter on the
 * lock. Remove the previous top waiter from
 * the tasks pi waiters list and add waiter to
 * it.
 */
rt_mutex_dequeue_pi(task, prerequeue_top_waiter);
rt_mutex_enqueue_pi(task, waiter);
__rt_mutex_adjust_prio(task);

} else if (prerequeue_top_waiter == waiter) {
/*
 * The waiter was the top waiter on the
 * lock. Remove waiter from the tasks pi
 * waiters list and add the new top waiter to
 * it.
 */
rt_mutex_dequeue_pi(task, waiter);
waiter = rt_mutex_top_waiter(lock);
rt_mutex_enqueue_pi(task, waiter);
__rt_mutex_adjust_prio(task);

} else {
/*
 * Nothing changed. No need to do any priority
 * adjustment.
 */
}

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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/