mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Tejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Chris Mason <chris.mason@oracle.com>,
	linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] mutex: Apply adaptive spinning on mutex_trylock()
Date: Fri, 25 Mar 2011 09:10:00 -0400	[thread overview]
Message-ID: <1301058600.14261.172.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <20110325065300.GB1409@htj.dyndns.org>

On Fri, 2011-03-25 at 07:53 +0100, Tejun Heo wrote:
> Hello, Steven, Linus.
> 
> On Thu, Mar 24, 2011 at 09:38:58PM -0700, Linus Torvalds wrote:
> > On Thu, Mar 24, 2011 at 8:39 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > But now, mutex_trylock(B) becomes a spinner too, and since the B's owner
> > > is running (spinning on A) it will spin as well waiting for A's owner to
> > > release it. Unfortunately, A's owner is also spinning waiting for B to
> > > release it.
> > >
> > > If both A and B's owners are real time tasks, then boom! deadlock.
> > 
> > Hmm. I think you're right. And it looks pretty fundamental - I don't
> > see any reasonable approach to avoid it.
> 
> Hmmm... I have an idea.  Will play with it a bit and post if it works
> out okay.

One solution is to have this be only done on explicit trylocks. Perhaps
introduce a mutex_trylock_spin()? Then when the developer knows that
this scenario does not exist, they can convert mutex_trylocks() into
this spinning version.

> 
> > I think the RT issue is a red herring too - afaik, you can get a
> > deadlock with two perfectly normal processes too. Of course, for
> > non-RT tasks, any other process will eventually disturb the situation
> > and you'd get kicked out due to need_resched(), but even that might be
> > avoided for a long time if there are other CPU's - leading to tons of
> > wasted CPU time.
> 
> Yeap, need_resched() currently is the only thing which limits the
> duration of spinning when the owner continues to run.

Yeah, I was about to complain about the long latencies that this could
cause, then I realized that RT tasks would in fact deadlock the system
here, which I thought was a bigger problem, and focused on that issue.

-- Steve



  reply	other threads:[~2011-03-25 13:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 15:37 [RFC PATCH] " Tejun Heo
2011-03-23 15:40 ` Tejun Heo
2011-03-23 15:48 ` Linus Torvalds
2011-03-23 15:52   ` Tejun Heo
2011-03-23 19:46   ` Andrey Kuzmin
2011-03-24  8:18 ` Ingo Molnar
2011-03-25  3:24   ` Steven Rostedt
2011-03-25 10:29     ` Ingo Molnar
2011-03-24  9:41 ` [PATCH 1/2] Subject: mutex: Separate out mutex_spin() Tejun Heo
2011-03-24  9:41   ` [PATCH 2/2] mutex: Apply adaptive spinning on mutex_trylock() Tejun Heo
2011-03-25  3:39     ` Steven Rostedt
2011-03-25  4:38       ` Linus Torvalds
2011-03-25  6:53         ` Tejun Heo
2011-03-25 13:10           ` Steven Rostedt [this message]
2011-03-25 13:29             ` Steven Rostedt
2011-03-25 11:13       ` Andrey Kuzmin
2011-03-25 13:12         ` Steven Rostedt
2011-03-25 13:50           ` Andrey Kuzmin
2011-03-25 14:05             ` Steven Rostedt
2011-03-25 19:51               ` Ingo Molnar
2011-03-25 10:12     ` Tejun Heo
2011-03-25 10:31       ` Ingo Molnar
2011-03-29 16:37       ` Tejun Heo
2011-03-29 17:09         ` Tejun Heo
2011-03-29 17:37           ` Peter Zijlstra
2011-03-30  8:17             ` Tejun Heo
2011-03-30 11:29               ` Peter Zijlstra
2011-03-30 11:46         ` Chris Mason
2011-03-30 11:52           ` Peter Zijlstra
2011-03-30 11:59             ` Chris Mason
2011-03-24  9:42   ` [PATCH 1/2] Subject: mutex: Separate out mutex_spin() Tejun Heo
2011-03-24 16:18 ` [tip:core/urgent] " tip-bot for Tejun Heo
2011-03-24 16:19 ` [tip:core/urgent] mutex: Do adaptive spinning in mutex_trylock() tip-bot for Tejun Heo

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=1301058600.14261.172.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®