From: Thomas Gleixner <tglx@linutronix.de>
To: Brad Mouring <bmouring@ni.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
linux-rt-users <linux-rt-users@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Clark Williams <williams@redhat.com>
Subject: Re: [PATCH 1/1] rtmutex: Handle when top lock owner changes
Date: Wed, 4 Jun 2014 21:53:16 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.10.1406042147080.18296@nanos> (raw)
In-Reply-To: <20140604192541.GA9496@linuxgetsreal>
On Wed, 4 Jun 2014, Brad Mouring wrote:
> On Wed, Jun 04, 2014 at 08:02:16PM +0200, Thomas Gleixner wrote:
> > I'll fixup the check so it wont break the real deadlock case and queue
> > it.
>
> How would the change break the real deadlock case?
> > /* Deadlock detection */
> > if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
> > + /*
> > + * If the prio chain has changed out from under us, set the task
> > + * to the current owner of the lock in the current waiter and
> > + * continue walking the prio chain
> > + */
> > + if (rt_mutex_owner(lock) && rt_mutex_owner(lock) != task) {
No, sorry. That's wrong.
Your change wreckages the rt_mutex_owner(lock) == top_task test
simply because in that case:
(rt_mutex_owner(lock) && rt_mutex_owner(lock) != task)
evaluates to true.
So we want this:
Index: tip/kernel/locking/rtmutex.c
===================================================================
--- tip.orig/kernel/locking/rtmutex.c
+++ tip/kernel/locking/rtmutex.c
@@ -375,6 +375,26 @@ static int rt_mutex_adjust_prio_chain(st
* walk, we detected a deadlock.
*/
if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
+ /*
+ * If the prio chain has changed out from under us, set the task
+ * to the current owner of the lock in the current waiter and
+ * continue walking the prio chain
+ */
+ if (rt_mutex_owner(lock) && rt_mutex_owner(lock) != task &&
+ rt_mutex_owner(lock) != top_task) {
+ /* Release the old owner */
+ raw_spin_unlock_irqrestore(&task->pi_lock, flags);
+ put_task_struct(task);
+
+ /* Move to the new owner */
+ task = rt_mutex_owner(lock);
+ get_task_struct(task);
+
+ /* Let's try this again */
+ raw_spin_unlock(&lock->wait_lock);
+ goto retry;
+ }
+
debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
raw_spin_unlock(&lock->wait_lock);
ret = deadlock_detect ? -EDEADLK : 0;
next prev parent reply other threads:[~2014-06-04 19:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1400855410-14773-1-git-send-email-brad.mouring@ni.com>
[not found] ` <1400855410-14773-2-git-send-email-brad.mouring@ni.com>
2014-06-04 1:06 ` [PATCH 1/1] rtmutex: Handle when top lock owner changes Steven Rostedt
2014-06-04 13:05 ` Brad Mouring
2014-06-04 14:16 ` Steven Rostedt
2014-06-04 14:38 ` Brad Mouring
2014-06-04 14:58 ` Steven Rostedt
2014-06-04 15:11 ` Brad Mouring
2014-06-04 15:32 ` Thomas Gleixner
2014-06-04 15:44 ` Steven Rostedt
2014-06-04 18:02 ` Thomas Gleixner
2014-06-04 18:12 ` Steven Rostedt
2014-06-04 20:49 ` Thomas Gleixner
2014-06-04 19:25 ` Brad Mouring
2014-06-04 19:53 ` Thomas Gleixner [this message]
2014-06-04 20:07 ` Brad Mouring
2014-06-04 20:41 ` Thomas Gleixner
2014-06-04 22:22 ` [PATCH] " Brad Mouring
2014-06-04 23:03 ` Thomas Gleixner
2014-06-06 3:19 ` [PATCH 1/1] " Steven Rostedt
2014-06-06 5:40 ` Thomas Gleixner
2014-06-06 5:44 ` Thomas Gleixner
2014-06-06 8:53 ` Steven Rostedt
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.10.1406042147080.18296@nanos \
--to=tglx@linutronix.de \
--cc=bmouring@ni.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=williams@redhat.com \
/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