From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Jason Baron <jbaron@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Nick Piggin <npiggin@kernel.dk>, Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>, KVM <kvm@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>,
Xen Devel <xen-devel@lists.xensource.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
konrad.wilk@oracle.com, rth@redhat.com
Subject: Re: [PATCH RFC V5 00/11] Paravirtualized ticketlocks
Date: Fri, 14 Oct 2011 12:02:43 -0700 [thread overview]
Message-ID: <4E988753.1080201@goop.org> (raw)
In-Reply-To: <20111014183539.GE2433@redhat.com>
On 10/14/2011 11:35 AM, Jason Baron wrote:
> On Fri, Oct 14, 2011 at 10:02:35AM -0700, Jeremy Fitzhardinge wrote:
>> On 10/14/2011 07:17 AM, Jason Baron wrote:
>>> On Thu, Oct 13, 2011 at 09:44:48AM -0700, Jeremy Fitzhardinge wrote:
>>>> pvops is basically a collection of ordinary _ops structures full of
>>>> function pointers, but it has a layer of patching to help optimise it.
>>>> In the common case, this just replaces an indirect call with a direct
>>>> one, but in some special cases it can inline code. This is used for
>>>> small, extremely performance-critical things like cli/sti, but it
>>>> awkward to use in general because you have to specify the inlined code
>>>> as a parameterless asm.
>>>>
>>> I haven't look at the pvops patching (probably should), but I was
>>> wondering if jump labels could be used for it? Or is there something
>>> that the pvops patching is doing that jump labels can't handle?
>> Jump labels are essentially binary: you can use path A or path B. pvops
>> are multiway: there's no limit to the number of potential number of
>> paravirtualized hypervisor implementations. At the moment we have 4:
>> native, Xen, KVM and lguest.
>>
> Yes, they are binary using the static_branch() interface. But in
> general, the asm goto() construct, allows branching to any number of
> labels. I have implemented the boolean static_branch() b/c it seems like
> the most common interface for jump labels, but I imagine we will
> introduce new interfaces as time goes on. You could of course nest
> static_branch() calls, although I can't say I've tried it.
At the moment we're using pvops to optimise things like:
(*pv_mmu_ops.set_pte)(...);
To do that with some kind of multiway jump label thing, then that would
need to expand out to something akin to:
if (static_branch(is_xen))
xen_set_pte(...);
else if (static_branch(is_kvm))
kvm_set_pte(...);
else if (static_branch(is_lguest))
lguest_set_pte(...);
else
native_set_pte(...);
or something similar with an actual jump table. But I don't see how it
offers much scope for improvement.
If there were something like:
STATIC_INDIRECT_CALL(&pv_mmu_ops.set_pte)(...);
where the apparently indirect call is actually patched to be a direct
call, then that would offer a large subset of what we do with pvops.
However, to completely replace pvops patching, the static branch / jump
label mechanism would also need to work in assembler code, and be
capable of actually patching callsites with instructions rather than
just calls (sti/cli/pushf/popf being the most important).
We also keep track of the live registers at the callsite, and compare
that to what registers the target functions will clobber in order to
optimise the amount of register save/restore is needed. And as a result
we have some pvops functions with non-standard calling conventions to
minimise save/restores on critical paths.
> We could have an interface, that allowed static branch(), to specifiy an
> arbitrary number of no-ops such that call-site itself could look anyway
> we want, if we don't know the bias at compile time. This, of course
> means potentially greater than 1 no-op in the fast path. I assume the
> pvops can have greater than 1 no-op in the fast path. Or is there a
> better solution here?
See above. But pvops patching is pretty well tuned for its job.
However, I definitely think its worth investigating some way to reduce
the number of patching mechanisms, and if pvops patching doesn't stretch
static jumps in unnatural ways, then perhaps that's the way to go.
Thanks,
J
next prev parent reply other threads:[~2011-10-14 19:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 0:51 [PATCH RFC V5 00/11] Paravirtualized ticketlocks Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 01/11] x86/spinlock: replace pv spinlocks with pv ticketlocks Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 02/11] x86/ticketlock: don't inline _spin_unlock when using paravirt spinlocks Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 03/11] x86/ticketlock: collapse a layer of functions Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 04/11] xen: defer spinlock setup until boot CPU setup Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 05/11] xen/pvticketlock: Xen implementation for PV ticket locks Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 06/11] xen/pvticketlocks: add xen_nopvspin parameter to disable xen pv ticketlocks Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 07/11] x86/pvticketlock: use callee-save for lock_spinning Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 08/11] x86/pvticketlock: when paravirtualizing ticket locks, increment by 2 Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 09/11] x86/ticketlock: add slowpath logic Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 10/11] xen/pvticketlock: allow interrupts to be enabled while blocking Jeremy Fitzhardinge
2011-10-13 0:51 ` [PATCH RFC V5 11/11] xen: enable PV ticketlocks on HVM Xen Jeremy Fitzhardinge
2011-10-13 10:54 ` [PATCH RFC V5 00/11] Paravirtualized ticketlocks Peter Zijlstra
2011-10-13 16:44 ` Jeremy Fitzhardinge
2011-10-14 14:17 ` Jason Baron
2011-10-14 17:02 ` Jeremy Fitzhardinge
2011-10-14 18:35 ` Jason Baron
2011-10-14 18:38 ` H. Peter Anvin
2011-10-14 18:51 ` Jeremy Fitzhardinge
2011-10-14 19:02 ` Jeremy Fitzhardinge [this message]
2011-10-17 14:58 ` Jason Baron
2011-10-14 18:37 ` H. Peter Anvin
2011-10-14 19:10 ` Jeremy Fitzhardinge
2011-10-14 19:12 ` H. Peter Anvin
2011-10-17 16:33 ` H. Peter Anvin
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=4E988753.1080201@goop.org \
--to=jeremy@goop.org \
--cc=andi@firstfloor.org \
--cc=avi@redhat.com \
--cc=hpa@zytor.com \
--cc=jbaron@redhat.com \
--cc=jeremy.fitzhardinge@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtosatti@redhat.com \
--cc=npiggin@kernel.dk \
--cc=peterz@infradead.org \
--cc=rth@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xensource.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;
as well as URLs for NNTP newsgroup(s).