linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>, Brad Mouring <bmouring@ni.com>
Subject: Re: [patch 2/2] rtmutex: Detect changes in the pi lock chain
Date: Fri, 6 Jun 2014 10:25:15 -0400	[thread overview]
Message-ID: <20140606102515.4e2c9574@gandalf.local.home> (raw)
In-Reply-To: <20140605152801.930031935@linutronix.de>

On Thu, 05 Jun 2014 15:28:33 -0000
Thomas Gleixner <tglx@linutronix.de> wrote:
 
> @@ -536,8 +569,9 @@ static int task_blocks_on_rt_mutex(struc
>  {
>  	struct task_struct *owner = rt_mutex_owner(lock);
>  	struct rt_mutex_waiter *top_waiter = waiter;
> +	struct rt_mutex *next_lock = NULL;
>  	unsigned long flags;
> -	int chain_walk = 0, res;
> +	int chain_walk, res;
>  
>  	/*
>  	 * Early deadlock detection. We really don't want the task to
> @@ -569,19 +603,21 @@ static int task_blocks_on_rt_mutex(struc
>  	if (!owner)
>  		return 0;
>  
> +	raw_spin_lock_irqsave(&owner->pi_lock, flags);
>  	if (waiter == rt_mutex_top_waiter(lock)) {
> -		raw_spin_lock_irqsave(&owner->pi_lock, flags);
>  		rt_mutex_dequeue_pi(owner, top_waiter);
>  		rt_mutex_enqueue_pi(owner, waiter);
>  
>  		__rt_mutex_adjust_prio(owner);
>  		if (owner->pi_blocked_on)
>  			chain_walk = 1;
> -		raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
> -	}
> -	else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock))
> +	} else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock)) {
>  		chain_walk = 1;
> +	}
> +	if (owner->pi_blocked_on)
> +		next_lock = owner->pi_blocked_on->lock;
>  
> +	raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
>  	if (!chain_walk)
>  		return 0;

Here's another optimization:

	/* If the owner is not blocked, no need to walk the chain */
	if (!chain_walk || !next_lock)
		return 0;



-- Steve

  parent reply	other threads:[~2014-06-06 14:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 15:28 [patch 0/2] rtmutex: Sanitze deadlock detection and chain walk Thomas Gleixner
2014-06-05 15:28 ` [patch 1/2] rtmutex: Handle deadlock detection smarter Thomas Gleixner
2014-06-06  1:14   ` Steven Rostedt
2014-06-06  5:41     ` Thomas Gleixner
2014-06-06  2:59   ` Steven Rostedt
2014-06-06  5:40     ` Thomas Gleixner
2014-06-09 16:49   ` [tip:locking/urgent] " tip-bot for Thomas Gleixner
2014-06-05 15:28 ` [patch 2/2] rtmutex: Detect changes in the pi lock chain Thomas Gleixner
2014-06-06  9:48   ` Peter Zijlstra
2014-06-06  9:58     ` Steven Rostedt
2014-06-06 14:25   ` Steven Rostedt [this message]
2014-06-06 14:49   ` Steven Rostedt
2014-06-07  7:31     ` Thomas Gleixner
2014-06-09 16:49   ` [tip:locking/urgent] " 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=20140606102515.4e2c9574@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=bmouring@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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).