From: Thomas Gleixner <tglx@linutronix.de>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Darren Hart <dvhart@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Mike Galbraith <umgwanakikbuti@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH -tip v2 1/2] locking/rtmutex: Support spin on owner
Date: Thu, 2 Jul 2015 00:27:39 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.11.1507020002170.3916@nanos> (raw)
In-Reply-To: <1435782588-4177-1-git-send-email-dave@stgolabs.net>
On Wed, 1 Jul 2015, Davidlohr Bueso wrote:
> Similar to what we have in other locks, particularly regular mutexes, the
> idea is that as long as the owner is running, there is a fair chance it'll
> release the lock soon, and thus a task trying to acquire the rtmutex will
> better off spinning instead of blocking immediately after the fastpath.
> Conditions to stop spinning and enter the slowpath are simple:
>
> (1) Upon need_resched()
> (2) Current lock owner blocks
>
> Because rtmutexes track the lock owner atomically, we can extend the fastpath
> to continue polling on the lock owner via cmpxchg(lock->owner, NULL, current).
>
> However, this is a conservative approach, such that if there are any waiters
> in-line, we stop spinning and immediately take the traditional slowpath. This
> allows priority boosting to take precedence over spinning, as otherwise we
> could starve a higher priority queued-up task (ie: top waiter) if spinners
> constantly steal the lock.
I'm a bit wary about the whole approach. In the RT tree we spin AFTER
we've enqueued the waiter and run priority boosting. While I can see
the charm of your approach, i.e. avoiding the prio boost dance for the
simple case, this can introduce larger latencies.
T1 (prio = 0) T2 (prio = 50)
lock(RTM);
lock(RTM);
spin()
-->preemption
T3 (prio = 10) leave spin, because owner is not on cpu
enqueue();
boost();
schedule();
-->preemption
T1 (prio = 50)
So we trade two extra context switches in the worst case for an
enhancement of performance in the normal case. I cannot quantify the
impact of this, but we really need to evaluate that proper before
going there.
Aside of that, if the lock is really contended, then you force all
spinners off the cpu, if one of the spinners starts blocking simply
because you have no idea which one is the top prio spinner.
T1 (prio = 0) T2 (prio = 50) T3 (prio = 10)
lock(RTM);
lock(RTM); lock(RTM);
spin() spin();
--> preemption
enqueue()
boost();
schedule();
sees waiter bit
enqueue();
boost();
schedule();
T2 could happily keep spinning despite T3 going to sleep. I'm not sure
if that's what we want to achieve.
Need to think about it some more, but I wanted to give you something
to think about as well :)
Thanks,
tglx
next prev parent reply other threads:[~2015-07-01 22:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 20:29 Davidlohr Bueso
2015-07-01 20:29 ` [PATCH 2/2] rtmutex: Delete scriptable tester Davidlohr Bueso
2015-07-20 10:58 ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2015-07-01 22:27 ` Thomas Gleixner [this message]
2015-07-02 0:16 ` [PATCH -tip v2 1/2] locking/rtmutex: Support spin on owner Davidlohr Bueso
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.1507020002170.3916@nanos \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=umgwanakikbuti@gmail.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
all inboxes | Powered by JetHome®