qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Jamie Lokier <jamie@shareable.org>
Cc: Carsten Otte <cotte@de.ibm.com>,
	Paul Brook <paul@codesourcery.com>,
	qemu-devel@nongnu.org, kvm-devel <kvm@vger.kernel.org>,
	Hollis Blanchard <hollisb@us.ibm.com>
Subject: Re: [Qemu-devel] [PATCH][RFC] Split non-TCG bits out of exec.c
Date: Fri, 14 Nov 2008 17:20:13 -0600	[thread overview]
Message-ID: <491E07AD.8030108@codemonkey.ws> (raw)
In-Reply-To: <20081114231309.GD19384@shareable.org>

Jamie Lokier wrote:
> Firstly:
>
> That doesn't make sense: why would you do an expensive TCG translation
> every time you hit the same code?  After the first encounter, if the
> code page hasn't been modified, it should be a TB cache lookup to
> already translated code.
>   

Except that once you run under KVM again, you lose all dirty information 
and you have to invalidate all TBs.

FWIW, a few years ago, we implemented this concept with QEMU and Xen.  
That's where my data is coming from.

> I'm guessing the cost of TB cache lookup is much closer to 3k than
> 300k cycles, maybe even lower...
>   

You're guessing and it doesn't matter anyway because the TB cache has to 
be invalidated.

> Secondly:
>
> In these cases, you can use a special fast translation (when it's not
> cached) which just copies the instructions 1:1 from the guest, simply
> converting the special instructions (MMIO, anything else needing it)
> to helper calls.  That's possible because you know the host is ture
> architeccompatible with the guest, as it's running KVM.
>   

You can't copy 1:1 because the instructions aren't 1:1.  Only trivial 
instructions that manipulate registers remain the same but even then, 
you have to do register renaming and on the x86 this probably means 
you'll have to spill some registers because you have so few.  Any memory 
reference (mov, push, pop, etc.) must be translated to a different 
instruction because you don't have a virtual address that can be 
accessed directly so you need a hook to simulate a tlb miss.

You can preserve atomicity if you try hard enough, but it certainly 
isn't a 1:1 translation in softmmu mode.

>> If you also consider all the potential locking issues with SMP guests, I 
>> think it's pretty likely that there are few cases where dropping to TCG 
>> is going to be a net performance win.
>>     
>
> VMware claimed otherwise when Intel first brought out CPU support for
> virtualisation.
>   

That's just not true.  The paper that you're most likely referencing was 
much more nuanced than that and the hardware has improved dramatically 
since then.

> SMP works fine if you map guest instructions 1:1 to host instructions
> with helper calls for special cases.  Even atomics, load-locked
> sequences and complex weak memory ordering things would behave
> correctly.
>   

You can't translate 1:1 so your argument falls apart.

Regards,

Anthony Liguori

> Oops, I believe I just argued for keeping the TB cache and code
> translation but not using TCG :-)
>
> -- Jamie
>   

      reply	other threads:[~2008-11-14 23:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12 22:10 [Qemu-devel] [PATCH][RFC] Split non-TCG bits out of exec.c Anthony Liguori
2008-11-12 22:48 ` Fabrice Bellard
2008-11-12 22:53   ` Anthony Liguori
2008-11-13 13:51 ` andrzej zaborowski
2008-11-13 16:18   ` Anthony Liguori
2008-11-14  3:12     ` andrzej zaborowski
2008-11-14  3:18       ` Anthony Liguori
2008-11-14 13:45         ` andrzej zaborowski
2008-11-14  4:03 ` Jamie Lokier
2008-11-14  9:58   ` Avi Kivity
2008-11-14 13:23     ` Jamie Lokier
2008-11-16 13:07       ` Avi Kivity
2008-11-17  3:57         ` Jamie Lokier
2008-11-14 13:58   ` Anthony Liguori
2008-11-14 14:07   ` Anthony Liguori
2008-11-14 23:13     ` Jamie Lokier
2008-11-14 23:20       ` Anthony Liguori [this message]

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=491E07AD.8030108@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=cotte@de.ibm.com \
    --cc=hollisb@us.ibm.com \
    --cc=jamie@shareable.org \
    --cc=kvm@vger.kernel.org \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).