Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1220014

Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack
Date 2015-09-07 11:20 +0200
Message-ID <q60KK-1gO-7@gated-at.bofh.it> (permalink)
References <q4NZf-3Zz-3@gated-at.bofh.it> <q5j35-6jH-41@gated-at.bofh.it> <q5kBP-bb-3@gated-at.bofh.it> <q5lez-Uu-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep() hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-04 03:30 +0200
  [RFC][PATCH RT 3/3] rt: Make cpu_chill() into yield() and add new cpu_rest() as msleep(1) Steven Rostedt <rostedt@goodmis.org> - 2015-09-04 03:30 +0200
  [RFC][PATCH RT 2/3] locking: Convert trylock spinners over to spin_try_or_boost_lock() Steven Rostedt <rostedt@goodmis.org> - 2015-09-04 03:30 +0200
  [RFC][PATCH RT 1/3] locking: Add spin_try_or_boost_lock() infrastructure Steven Rostedt <rostedt@goodmis.org> - 2015-09-04 03:30 +0200
    Re: [RFC][PATCH RT 1/3] locking: Add spin_try_or_boost_lock()  infrastructure Steven Rostedt <rostedt@goodmis.org> - 2015-09-04 03:50 +0200
  Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Thomas Gleixner <tglx@linutronix.de> - 2015-09-05 12:40 +0200
    Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Ingo Molnar <mingo@kernel.org> - 2015-09-05 14:10 +0200
      Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-05 14:30 +0200
      Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Thomas Gleixner <tglx@linutronix.de> - 2015-09-07 10:40 +0200
        Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Thomas Gleixner <tglx@linutronix.de> - 2015-09-07 12:20 +0200
        Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Ingo Molnar <mingo@kernel.org> - 2015-09-08 09:40 +0200
          Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Thomas Gleixner <tglx@linutronix.de> - 2015-09-08 10:20 +0200
            Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Ingo Molnar <mingo@kernel.org> - 2015-09-14 12:00 +0200
        Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-08 19:00 +0200
          Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-08 21:40 +0200
    Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-05 14:20 +0200
      Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-05 14:30 +0200
      Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Steven Rostedt <rostedt@goodmis.org> - 2015-09-05 15:00 +0200
        Re: [RFC][PATCH RT 0/3] RT: Fix trylock deadlock without msleep()  hack Thomas Gleixner <tglx@linutronix.de> - 2015-09-07 11:20 +0200

csiph-web