From patchwork Tue Apr 16 06:32:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 2448011 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D9911DF230 for ; Tue, 16 Apr 2013 06:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755378Ab3DPGjm (ORCPT ); Tue, 16 Apr 2013 02:39:42 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:33708 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753766Ab3DPGjk (ORCPT ); Tue, 16 Apr 2013 02:39:40 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Apr 2013 16:30:38 +1000 Received: from d23relay03.au.ibm.com (202.81.31.245) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Apr 2013 16:30:35 +1000 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3G6ZNl130933172; Tue, 16 Apr 2013 16:35:26 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3G6Z4Kw018276; Tue, 16 Apr 2013 16:35:05 +1000 Received: from localhost (dhcp-9-111-29-110.cn.ibm.com [9.111.29.110]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3G6Yt0m017881; Tue, 16 Apr 2013 16:35:02 +1000 From: Xiao Guangrong To: mtosatti@redhat.com Cc: gleb@redhat.com, avi.kivity@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Xiao Guangrong Subject: [PATCH v3 09/15] KVM: MMU: introduce free_meslot_rmap_desc_nolock Date: Tue, 16 Apr 2013 14:32:47 +0800 Message-Id: <1366093973-2617-10-git-send-email-xiaoguangrong@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1366093973-2617-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> References: <1366093973-2617-1-git-send-email-xiaoguangrong@linux.vnet.ibm.com> x-cbid: 13041606-3568-0000-0000-000003702C34 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org It frees pte-list-descs used by memslot rmap after update memslot is completed Signed-off-by: Xiao Guangrong --- arch/x86/kvm/mmu.c | 26 ++++++++++++++++++++++++++ arch/x86/kvm/mmu.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index e6414d2..9ac584f 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1049,6 +1049,22 @@ static void pte_list_clear_concurrently(u64 *spte, unsigned long *pte_list) return; } +static void pte_list_free_desc(unsigned long *pte_list) +{ + struct pte_list_desc *desc, *next; + unsigned long pte_value = *pte_list; + + if (!(pte_value & 1)) + return; + + desc = (struct pte_list_desc *)(pte_value & ~1ul); + do { + next = desc->more; + mmu_free_pte_list_desc(desc); + desc = next; + } while (desc); +} + typedef void (*pte_list_walk_fn) (u64 *spte); static void pte_list_walk(unsigned long *pte_list, pte_list_walk_fn fn) { @@ -1786,6 +1802,16 @@ unmap_memslot_rmap_nolock(struct kvm *kvm, struct kvm_memory_slot *slot) walk_memslot_rmap_nolock(slot, unmap_invalid_rmap_nolock, kvm); } +static void free_rmap_desc_nolock(unsigned long *rmapp, void *data) +{ + pte_list_free_desc(rmapp); +} + +void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot) +{ + walk_memslot_rmap_nolock(slot, free_rmap_desc_nolock, NULL); +} + #ifdef MMU_DEBUG static int is_empty_shadow_page(u64 *spt) { diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index d6aa31a..ab434b7 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -130,4 +130,5 @@ struct rmap_operations { }; void init_memslot_rmap_ops(struct kvm_memory_slot *slot); +void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot); #endif