lkml.org 
[lkml]   [2013]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH v2 12/12] KVM: MMU: fast drop all spte on the pte_list
    If the pte_list need to be destroyed, no need to delete its spte one
    by one, we can directly reset it and free the memory its used

    Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
    ---
    arch/x86/kvm/mmu.c | 36 +++++++++++++++++++++++++++---------
    1 files changed, 27 insertions(+), 9 deletions(-)

    diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
    index 2c0a786..0afe8da 100644
    --- a/arch/x86/kvm/mmu.c
    +++ b/arch/x86/kvm/mmu.c
    @@ -968,6 +968,25 @@ static void pte_list_remove(u64 *spte, unsigned long *pte_list)
    }
    }

    +static void pte_list_destroy(unsigned long *pte_list)
    +{
    + struct pte_list_desc *desc;
    + unsigned long list_value = *pte_list;
    +
    + *pte_list = 0;
    +
    + if (!(list_value & 1))
    + return;
    +
    + desc = (struct pte_list_desc *)(list_value & ~1ul);
    + while (desc) {
    + struct pte_list_desc *next_desc = desc->more;
    +
    + mmu_free_pte_list_desc(desc);
    + desc = next_desc;
    + }
    +}
    +
    /*
    * Used by the following functions to iterate through the sptes linked by a
    * pte_list. All fields are private and not assumed to be used outside.
    @@ -1206,17 +1225,17 @@ static bool rmap_write_protect(struct kvm *kvm, u64 gfn)
    static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
    struct kvm_memory_slot *slot, unsigned long data)
    {
    - u64 *sptep;
    struct pte_list_iterator iter;
    + u64 *sptep;
    int need_tlb_flush = 0;

    -restart:
    for_each_spte_in_rmap(*rmapp, iter, sptep) {
    - drop_spte(kvm, sptep);
    + mmu_spte_clear_track_bits(sptep);
    need_tlb_flush = 1;
    - goto restart;
    }

    + pte_list_destroy(rmapp);
    +
    return need_tlb_flush;
    }

    @@ -2041,11 +2060,10 @@ static void kvm_mmu_unlink_parents(struct kvm *kvm, struct kvm_mmu_page *sp)
    u64 *sptep;
    struct pte_list_iterator iter;

    -restart:
    - for_each_spte_in_rmap(sp->parent_ptes, iter, sptep) {
    - drop_parent_pte(sp, sptep);
    - goto restart;
    - }
    + for_each_spte_in_rmap(sp->parent_ptes, iter, sptep)
    + mmu_spte_clear_no_track(sptep);
    +
    + pte_list_destroy(&sp->parent_ptes);
    }

    static int mmu_zap_unsync_children(struct kvm *kvm,
    --
    1.7.7.6


    \
     
     \ /
      Last update: 2013-01-23 12:02    [W:2.379 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site