linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Jason Low <jason.low2@hp.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: Re: [patch 6/6] rtmutex: Avoid pointless requeueing in the deadlock detection chain walk
Date: Wed, 28 May 2014 11:43:16 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1405281143000.21720@ionos.tec.linutronix.de> (raw)
In-Reply-To: <CAGQ1y=6DOs0hcdV+NvOdA9hxf6kwu-R0M-c6R2iUK4ufr=pwEg@mail.gmail.com>

On Tue, 27 May 2014, Jason Low wrote:
> On Wed, May 21, 2014 at 8:25 PM, Thomas Gleixner <tglx@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.

 

  reply	other threads:[~2014-05-28  9:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22  3:25 [patch 0/6] rtmutex: Repair deadlock detector and cleanup Thomas Gleixner
2014-05-22  3:25 ` [patch 1/6] rtmutex: Fix deadlock detector for real Thomas Gleixner
2014-05-27 22:09   ` Steven Rostedt
2014-05-28  9:57     ` Thomas Gleixner
2014-05-28 19:28   ` [tip:core/urgent] " tip-bot for Thomas Gleixner
2014-05-22  3:25 ` [patch 2/6] rtmutex: Remove builtin tester Thomas Gleixner
2014-05-30 21:36   ` Steven Rostedt
2014-05-22  3:25 ` [patch 3/6] rtmutex: Cleanup deadlock detector debug logic Thomas Gleixner
2014-05-30 22:08   ` Steven Rostedt
2014-06-21 20:32   ` [tip:locking/core] " tip-bot for Thomas Gleixner
2014-05-22  3:25 ` [patch 4/6] rtmutex: Confine deadlock logic to futex Thomas Gleixner
2014-05-22  7:10   ` Peter Zijlstra
2014-05-28 20:28     ` Thomas Gleixner
2014-05-31  2:06   ` Steven Rostedt
2014-05-22  3:25 ` [patch 5/6] rtmutex: Clarify the lock chain walk Thomas Gleixner
2014-05-31  2:19   ` Steven Rostedt
2014-05-22  3:25 ` [patch 6/6] rtmutex: Avoid pointless requeueing in the deadlock detection " Thomas Gleixner
2014-05-27 22:49   ` Jason Low
2014-05-28  9:43     ` Thomas Gleixner [this message]
2014-05-31  2:21       ` Steven Rostedt
2014-06-21 20:33   ` [tip:locking/core] " tip-bot for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1405281143000.21720@ionos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=jason.low2@hp.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).