From: William Lee Irwin III <wli@holomorphy.com>
To: Anton Blanchard <anton@samba.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Zwane Mwaikambo <zwane@linuxpower.ca>,
Andrew Morton <akpm@osdl.org>,
torvalds@osdl.org, paulus@samba.org,
linux-kernel@vger.kernel.org, jun.nakajima@intel.com, ak@suse.de,
mingo@elte.hu
Subject: Re: [PATCH] Yielding processor resources during lock contention
Date: Sat, 11 Sep 2004 23:58:52 -0700 [thread overview]
Message-ID: <20040912065852.GG2660@holomorphy.com> (raw)
In-Reply-To: <20040912060904.GJ32755@krispykreme>
At some point in the past, Nick Piggin wrote:
>> OK that sounds alight.
>> If it is a "I'm going to be spinning for ages, so schedule me off *now*"
>> then I think it is wrong... but if it just allows you to keep the hypervisor
>> preemption turned on, then fine.
On Sun, Sep 12, 2004 at 04:09:04PM +1000, Anton Blanchard wrote:
> The hypervisor can preempt us anywhere but we can give it clues so it
> tends to preempt us at better times.
> Within a few instructions the hypervisor should be able to answer the
> big question: is the cpu Im waiting for currently scheduled on another
> cpu. If it is then it might be best for the hypervisor to leave us
> alone.
> If it isnt then the spin time will most likely be dominated by how
> long it takes to get that cpu scheduled again and the hypervisor should
> make an effort to schedule it.
Preemption of a guest holding a busywait-protected resource is
catastrophic, yes. Voluntarily yielding to the host is one of the
few tactics a guest can use, alongside more widespread use of blocking
locking primitives and using host-provided locking primitives.
Gang scheduling in the host is stronger medicine for this, and has the
further advantage that it does not confuse contention with host
preemption. It may be valuable for Linux likewise to implement gang
scheduling to accommodate its own usage as a host, as futexes are only
usable when the guest issues system calls natively (as is the case in
UML; guests in full CPU emulators may not even be executing native
instructions).
I suspect that the optimal configuration would use 2-tier locking in
addition to gang scheduling the guests, where the outer tier busywaits
for some interval before backing off to an inner tier using a host-
provided locking primitive (obviously the host should not suspend the
entire gang when a guest blocks on the host-provided locking primitive).
It's unclear whether some attempt should be made to avoid the host-
provided wakeup portion of the locking primitives. The 2-tier locking
algorithms are still beneficial in the absence of gang scheduling, as
spurious host context switches likely carry a high cost; the backoff
should be arranged so that busywait is only done as long as the
expected cost of a spurious host context switch remains greater than
the expected cost of busywaiting during a host preemption, where in
the presence of gang scheduling the latter cost is merely lock contention
(i.e. gang scheduling allows guests to busywait as long as they expect
the latency of lock acquisition to be smaller than a host context switch,
where the longer one has busywaited the longer one expectes to busywait).
I suppose the first step is to get a hook for the host primitives into
the locking algorithms, so I approve of all this etc.
-- wli
next prev parent reply other threads:[~2004-09-12 6:59 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-03 0:02 [PATCH][5/8] Arch agnostic completely out of line locks / ppc64 Zwane Mwaikambo
2004-09-09 5:42 ` Paul Mackerras
2004-09-09 12:41 ` Zwane Mwaikambo
2004-09-09 14:54 ` Linus Torvalds
2004-09-09 14:55 ` Linus Torvalds
2004-09-09 15:32 ` Zwane Mwaikambo
2004-09-12 4:59 ` [PATCH] Yielding processor resources during lock contention Zwane Mwaikambo
2004-09-12 5:00 ` Andrew Morton
2004-09-12 5:10 ` Anton Blanchard
2004-09-12 5:13 ` Zwane Mwaikambo
2004-09-12 4:32 ` Nick Piggin
2004-09-12 5:33 ` Zwane Mwaikambo
2004-09-12 4:46 ` Nick Piggin
2004-09-12 5:51 ` Zwane Mwaikambo
2004-09-12 5:02 ` Nick Piggin
2004-09-12 6:09 ` Anton Blanchard
2004-09-12 6:58 ` William Lee Irwin III [this message]
2004-09-12 5:18 ` Andrew Morton
2004-09-12 5:10 ` Linus Torvalds
2004-09-12 5:27 ` Zwane Mwaikambo
2004-09-13 12:21 ` [PATCH] Yielding processor resources during lock contention #2 Zwane Mwaikambo
2004-09-12 7:49 ` [PATCH] Yielding processor resources during lock contention Ingo Molnar
2004-09-12 16:10 ` Zwane Mwaikambo
2004-09-12 19:34 ` Ingo Molnar
2004-09-12 10:10 ` Arnd Bergmann
2004-09-12 10:43 ` Anton Blanchard
2004-09-12 11:12 ` Arnd Bergmann
2004-09-09 15:43 ` [PATCH][5/8] Arch agnostic completely out of line locks / ppc64 Anton Blanchard
2004-09-09 17:19 ` William Lee Irwin III
2004-09-09 21:38 ` Paul Mackerras
2004-09-09 22:00 ` William Lee Irwin III
2004-09-09 23:36 ` Paul Mackerras
2004-09-10 0:09 ` William Lee Irwin III
2004-09-10 0:21 ` Linus Torvalds
2004-09-10 0:35 ` Anton Blanchard
2004-09-10 0:54 ` Linus Torvalds
2004-09-10 1:42 ` Anton Blanchard
2004-09-10 1:50 ` Anton Blanchard
2004-09-10 2:22 ` William Lee Irwin III
2004-09-10 2:32 ` William Lee Irwin III
2004-09-10 2:37 ` William Lee Irwin III
2004-09-10 3:24 ` Anton Blanchard
2004-09-10 7:40 ` Ingo Molnar
2004-09-10 12:16 ` William Lee Irwin III
2004-09-10 12:22 ` Ingo Molnar
2004-09-10 3:23 ` Anton Blanchard
2004-09-10 7:56 ` Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2004-09-13 0:45 [PATCH] Yielding processor resources during lock contention Nakajima, Jun
2004-09-13 1:35 Nakajima, Jun
2004-09-13 6:35 ` Ingo Molnar
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=20040912065852.GG2660@holomorphy.com \
--to=wli@holomorphy.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=anton@samba.org \
--cc=jun.nakajima@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=nickpiggin@yahoo.com.au \
--cc=paulus@samba.org \
--cc=torvalds@osdl.org \
--cc=zwane@linuxpower.ca \
/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