From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: gleb@redhat.com, avi.kivity@gmail.com, mtosatti@redhat.com,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v5 8/8] KVM: MMU: zap pages in batch
Date: Thu, 16 May 2013 21:31:24 +0800 [thread overview]
Message-ID: <5194DFAC.8010707@linux.vnet.ibm.com> (raw)
In-Reply-To: <5194D507.5080005@redhat.com>
On 05/16/2013 08:45 PM, Paolo Bonzini wrote:
> Il 16/05/2013 14:17, Xiao Guangrong ha scritto:
>> Zap at lease 10 pages before releasing mmu-lock to reduce the overload
>> caused by requiring lock
>>
>> [ It improves kernel building 0.6% ~ 1% ]
>>
>> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
>> ---
>> arch/x86/kvm/mmu.c | 11 ++++++++---
>> 1 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
>> index e12f431..9c27fda 100644
>> --- a/arch/x86/kvm/mmu.c
>> +++ b/arch/x86/kvm/mmu.c
>> @@ -4216,10 +4216,12 @@ restart:
>> spin_unlock(&kvm->mmu_lock);
>> }
>>
>> +#define BATCH_ZAP_PAGES 10
>> static void zap_invalid_pages(struct kvm *kvm)
>> {
>> struct kvm_mmu_page *sp, *node;
>> LIST_HEAD(invalid_list);
>> + int batch = 0;
>>
>> restart:
>> list_for_each_entry_safe(sp, node, &kvm->arch.active_mmu_pages, link) {
>> @@ -4256,11 +4258,14 @@ restart:
>> * Need not flush tlb since we only zap the sp with invalid
>> * generation number.
>> */
>> - if (cond_resched_lock(&kvm->mmu_lock))
>> + if ((batch >= BATCH_ZAP_PAGES) &&
>> + cond_resched_lock(&kvm->mmu_lock)) {
>> + batch = 0;
>> goto restart;
>> + }
>>
>> - if (kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list))
>> - goto restart;
>> + batch += kvm_mmu_prepare_zap_page(kvm, sp, &invalid_list);
>> + goto restart;
>
> Would this look again and again at the same page if
> kvm_mmu_prepare_zap_page returns 0?
We skip the invalid page (sp->role.invalid) before call
kvm_mmu_prepare_zap_page so that kvm_mmu_prepare_zap_page can not
meet the same page. ;)
next prev parent reply other threads:[~2013-05-16 13:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 12:17 [PATCH v5 0/8] KVM: MMU: fast zap all shadow pages Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 1/8] KVM: MMU: drop unnecessary kvm_reload_remote_mmus Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 2/8] KVM: MMU: delete shadow page from hash list in kvm_mmu_prepare_zap_page Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 3/8] KVM: MMU: fast invalidate all pages Xiao Guangrong
2013-05-16 12:43 ` Gleb Natapov
2013-05-16 13:14 ` Paolo Bonzini
2013-05-16 13:41 ` Gleb Natapov
2013-05-16 13:49 ` Paolo Bonzini
2013-05-16 13:25 ` Xiao Guangrong
2013-05-16 13:43 ` Gleb Natapov
2013-05-16 15:57 ` Gleb Natapov
2013-05-16 18:39 ` Xiao Guangrong
2013-05-16 19:57 ` Gleb Natapov
2013-05-16 16:18 ` Gleb Natapov
2013-05-16 18:40 ` Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 4/8] KVM: x86: use the fast way to " Xiao Guangrong
2013-05-16 16:19 ` Gleb Natapov
2013-05-16 18:45 ` Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 5/8] KVM: MMU: make kvm_mmu_zap_all preemptable Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 6/8] KVM: MMU: show mmu_valid_gen in shadow page related tracepoints Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 7/8] KVM: MMU: add tracepoint for kvm_mmu_invalidate_memslot_pages Xiao Guangrong
2013-05-16 12:17 ` [PATCH v5 8/8] KVM: MMU: zap pages in batch Xiao Guangrong
2013-05-16 12:45 ` Paolo Bonzini
2013-05-16 13:31 ` Xiao Guangrong [this message]
2013-05-16 12:20 ` [PATCH v5 0/8] KVM: MMU: fast zap all shadow pages Xiao Guangrong
2013-05-16 14:36 ` Takuya Yoshikawa
2013-05-16 18:26 ` Xiao Guangrong
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=5194DFAC.8010707@linux.vnet.ibm.com \
--to=xiaoguangrong@linux.vnet.ibm.com \
--cc=avi.kivity@gmail.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.