lkml.org 
[lkml]   [2013]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v5 8/8] KVM: MMU: zap pages in batch
    Date
    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;
    }

    /*
    --
    1.7.7.6


    \
     
     \ /
      Last update: 2013-05-16 15:01    [W:2.244 / U:0.192 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site