public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
	linux-rt-users <linux-rt-users@vger.kernel.org>,
	Carsten Emde <C.Emde@osadl.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	John Kacur <jkacur@redhat.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Clark Williams <clark.williams@gmail.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack
Date: Mon, 7 Sep 2015 11:14:43 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.11.1509071110130.15006@nanos> (raw)
In-Reply-To: <20150905085048.5cefbf5b@gandalf.local.home>

On Sat, 5 Sep 2015, Steven Rostedt wrote:

> On Sat, 5 Sep 2015 08:18:36 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > On Sat, 5 Sep 2015 12:30:59 +0200 (CEST)
> > Thomas Gleixner <tglx@linutronix.de> wrote:
> > > 
> > > So instead of doing that proposed magic boost, we can do something
> > > more straight forward:
> > > 
> > > retry:
> > > 	lock(B);
> > > 	if (!try_lock(A)) {
> > > 		lock_and_drop(A, B);
> > > 		unlock(A);
> > > 		goto retry;
> > > 	}
> > > 
> > > lock_and_drop() queues the task as a waiter on A, drops B and then
> > > does the PI adjustment on A. 
> > 
> > That was my original solution, and I believe I added patches to do
> > exactly that to the networking code in the past. I remember writing
> > that helper function such that on non PREEMPT_RT it was a nop.
> 
> Just to point out again that I misread what you wrote. That's what I
> get for responding to email 10 minutes after I get out of bed ;-)
> 
> 
> You need to be careful about adding the waiter on A. If the owner of A
> is blocked on B, the pi inheritance may detect that as a deadlock.

That's exactly why I wrote:

> > > lock_and_drop() queues the task as a waiter on A, drops B and then
> > > does the PI adjustment on A. 

because the PI adjustment would detect the deadlock.

Now the real question is whether we need that complexity at all. We
need to analyze the life time rules. If we have something like this:

     lock(y->lock);
     x = y->x;
     ...

and x cannot go away under us, then we can simply do

     lock(y->lock);
     x = y->x;
     if (!trylock(x->lock)) {
     	unlock(y->lock);
	lock(x->lock);
	unlock(x->lock);
	goto retry;
     }

Thanks,

	tglx

      reply	other threads:[~2015-09-07  9:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04  1:19 [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Steven Rostedt
2015-09-04  1:19 ` [RFC][PATCH RT 1/3] locking: Add spin_try_or_boost_lock() infrastructure Steven Rostedt
2015-09-04  1:48   ` Steven Rostedt
2015-09-04  1:19 ` [RFC][PATCH RT 2/3] locking: Convert trylock spinners over to spin_try_or_boost_lock() Steven Rostedt
2015-09-04  1:19 ` [RFC][PATCH RT 3/3] rt: Make cpu_chill() into yield() and add new cpu_rest() as msleep(1) Steven Rostedt
2015-09-05 10:30 ` [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Thomas Gleixner
2015-09-05 12:04   ` Ingo Molnar
2015-09-05 12:26     ` Steven Rostedt
2015-09-07  8:35     ` Thomas Gleixner
2015-09-07 10:10       ` Thomas Gleixner
2015-09-08  7:31       ` Ingo Molnar
2015-09-08  8:09         ` Thomas Gleixner
2015-09-14  9:50           ` Ingo Molnar
2015-09-08 16:59       ` Steven Rostedt
2015-09-08 19:35         ` Steven Rostedt
2015-09-05 12:18   ` Steven Rostedt
2015-09-05 12:27     ` Steven Rostedt
2015-09-05 12:50     ` Steven Rostedt
2015-09-07  9:14       ` Thomas Gleixner [this message]

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.11.1509071110130.15006@nanos \
    --to=tglx@linutronix.de \
    --cc=C.Emde@osadl.org \
    --cc=acme@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=clark.williams@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --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