public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Eric Northup <digitaleric@google.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Gleb Natapov <gleb@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: Re: [PATCH 5/5] KVM: MMU: fast invalid all mmio sptes
Date: Tue, 19 Mar 2013 11:15:36 +0800	[thread overview]
Message-ID: <5147D858.4010805@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAG7+5M0Z+HLxUf6n6=D3uqKhn3F2NbKU6tcHYtD6gyF3t8iHsw@mail.gmail.com>

On 03/19/2013 06:16 AM, Eric Northup wrote:
> On Fri, Mar 15, 2013 at 8:29 AM, Xiao Guangrong
> <xiaoguangrong@linux.vnet.ibm.com> wrote:
>> This patch tries to introduce a very simple and scale way to invalid all
>> mmio sptes - it need not walk any shadow pages and hold mmu-lock
>>
>> KVM maintains a global mmio invalid generation-number which is stored in
>> kvm->arch.mmio_invalid_gen and every mmio spte stores the current global
>> generation-number into his available bits when it is created
>>
>> When KVM need zap all mmio sptes, it just simply increase the global
>> generation-number. When guests do mmio access, KVM intercepts a MMIO #PF
>> then it walks the shadow page table and get the mmio spte. If the
>> generation-number on the spte does not equal the global generation-number,
>> it will go to the normal #PF handler to update the mmio spte
>>
>> Since 19 bits are used to store generation-number on mmio spte, the
>> generation-number can be round after 33554432 times. It is large enough
>> for nearly all most cases, but making the code be more strong, we zap all
>> shadow pages when the number is round
>>
>> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>> ---
>>  arch/x86/include/asm/kvm_host.h |    2 +
>>  arch/x86/kvm/mmu.c              |   61 +++++++++++++++++++++++++++++++++------
>>  arch/x86/kvm/mmutrace.h         |   17 +++++++++++
>>  arch/x86/kvm/paging_tmpl.h      |    7 +++-
>>  arch/x86/kvm/vmx.c              |    4 ++
>>  arch/x86/kvm/x86.c              |    6 +--
>>  6 files changed, 82 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index ef7f4a5..572398e 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -529,6 +529,7 @@ struct kvm_arch {
>>         unsigned int n_requested_mmu_pages;
>>         unsigned int n_max_mmu_pages;
>>         unsigned int indirect_shadow_pages;
>> +       unsigned int mmio_invalid_gen;
> 
> Could this get initialized to something close to the wrap-around
> value, so that the wrap-around case gets more real-world coverage?

I am afraid we can not. We cache the current mmio_invalid_gen into mmio spte when
it is created no matter what the initiation value is.

If you have a better way, please show me. ;)




  reply	other threads:[~2013-03-19  3:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 15:26 [PATCH 0/5] KVM: MMU: fast invalid all mmio sptes Xiao Guangrong
2013-03-15 15:26 ` [PATCH 1/5] Revert "KVM: x86: Optimize mmio spte zapping when, creating/moving memslot" Xiao Guangrong
2013-03-16  2:07   ` Takuya Yoshikawa
2013-03-18  7:36     ` Xiao Guangrong
2013-03-15 15:27 ` [PATCH 2/5] Revert "KVM: MMU: Mark sp mmio cached when creating mmio spte" Xiao Guangrong
2013-03-15 15:28 ` [PATCH 3/5] KVM: MMU: retain more available bits available on mmio spte Xiao Guangrong
2013-03-15 15:29 ` [PATCH 4/5] KVM: MMU: store generation-number into " Xiao Guangrong
2013-03-18 11:19   ` Paolo Bonzini
2013-03-18 12:42     ` Xiao Guangrong
2013-03-18 12:48       ` Gleb Natapov
2013-03-20 18:43       ` Marcelo Tosatti
2013-03-15 15:29 ` [PATCH 5/5] KVM: MMU: fast invalid all mmio sptes Xiao Guangrong
2013-03-16  2:13   ` Takuya Yoshikawa
2013-03-18  7:38     ` Xiao Guangrong
2013-03-17 15:02   ` Gleb Natapov
2013-03-18  8:08     ` Xiao Guangrong
2013-03-18  9:13       ` Gleb Natapov
2013-03-18 12:29         ` Xiao Guangrong
2013-03-18 12:46           ` Gleb Natapov
2013-03-18 13:09             ` Xiao Guangrong
2013-03-18 13:19               ` Gleb Natapov
2013-03-18 13:25                 ` Xiao Guangrong
2013-03-18 13:27                   ` Gleb Natapov
2013-03-18 13:32                     ` Xiao Guangrong
2013-03-18 22:16   ` Eric Northup
2013-03-19  3:15     ` Xiao Guangrong [this message]
2013-03-19  7:36       ` Gleb Natapov
2013-03-19  7:52         ` Xiao Guangrong
2013-03-16  2:06 ` [PATCH 0/5] " Takuya Yoshikawa

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=5147D858.4010805@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=digitaleric@google.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.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