From patchwork Wed Sep 23 18:47:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Izik Eidus X-Patchwork-Id: 49587 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8NIcf0I001418 for ; Wed, 23 Sep 2009 18:38:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752962AbZIWSif (ORCPT ); Wed, 23 Sep 2009 14:38:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753181AbZIWSif (ORCPT ); Wed, 23 Sep 2009 14:38:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752353AbZIWSif (ORCPT ); Wed, 23 Sep 2009 14:38:35 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8NIccUf004431 for ; Wed, 23 Sep 2009 14:38:39 -0400 Received: from localhost.localdomain (dhcp-1-211.tlv.redhat.com [10.35.1.211]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8NIcPev013485; Wed, 23 Sep 2009 14:38:35 -0400 From: Izik Eidus To: avi@redhat.com Cc: kvm@vger.kernel.org, aarcange@redhat.com, mtosatti@redhat.com, Izik Eidus Subject: [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Date: Wed, 23 Sep 2009 21:47:16 +0300 Message-Id: <1253731638-24575-2-git-send-email-ieidus@redhat.com> In-Reply-To: <1253731638-24575-1-git-send-email-ieidus@redhat.com> References: <1253731638-24575-1-git-send-email-ieidus@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When using mmu notifiers, we are allowed to remove the page count reference tooken by get_user_pages to a specific page that is mapped inside the shadow page tables. This is needed so we can balance the pagecount against mapcount checking. (Right now kvm increase the pagecount and does not increase the mapcount when mapping page into shadow page table entry, so when comparing pagecount against mapcount, you have no reliable result.) Signed-off-by: Izik Eidus Acked-by: Andrea Arcangeli --- arch/x86/kvm/mmu.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index eca41ae..6c67b23 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -634,9 +634,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte) if (*spte & shadow_accessed_mask) kvm_set_pfn_accessed(pfn); if (is_writeble_pte(*spte)) - kvm_release_pfn_dirty(pfn); - else - kvm_release_pfn_clean(pfn); + kvm_set_pfn_dirty(pfn); rmapp = gfn_to_rmap(kvm, sp->gfns[spte - sp->spt], sp->role.level); if (!*rmapp) { printk(KERN_ERR "rmap_remove: %p %llx 0->BUG\n", spte, *spte); @@ -1877,8 +1875,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, page_header_update_slot(vcpu->kvm, sptep, gfn); if (!was_rmapped) { rmap_count = rmap_add(vcpu, sptep, gfn); - if (!is_rmap_spte(*sptep)) - kvm_release_pfn_clean(pfn); + kvm_release_pfn_clean(pfn); if (rmap_count > RMAP_RECYCLE_THRESHOLD) rmap_recycle(vcpu, sptep, gfn); } else {