From: Izik Eidus <ieidus@redhat.com> To: unlisted-recipients:; (no To-header on input) Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, avi@redhat.com, aarcange@redhat.com, chrisw@redhat.com, riel@redhat.com, jeremy@goop.org, mtosatti@redhat.com, hugh@veritas.com, corbet@lwn.net, yaniv@redhat.com, dmonakhov@openvz.org, Izik Eidus <ieidus@redhat.com> Subject: [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages. Date: Tue, 31 Mar 2009 03:00:02 +0300 [thread overview] Message-ID: <1238457604-7637-2-git-send-email-ieidus@redhat.com> (raw) In-Reply-To: <1238457604-7637-1-git-send-email-ieidus@redhat.com> 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 <ieidus@redhat.com> --- 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 b625ed4..df8fbaf 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -567,9 +567,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], is_large_pte(*spte)); if (!*rmapp) { printk(KERN_ERR "rmap_remove: %p %llx 0->BUG\n", spte, *spte); @@ -1812,8 +1810,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, page_header_update_slot(vcpu->kvm, shadow_pte, gfn); if (!was_rmapped) { rmap_add(vcpu, shadow_pte, gfn, largepage); - if (!is_rmap_pte(*shadow_pte)) - kvm_release_pfn_clean(pfn); + kvm_release_pfn_clean(pfn); } else { if (was_writeble) kvm_release_pfn_dirty(pfn); -- 1.5.6.5
WARNING: multiple messages have this Message-ID (diff)
From: Izik Eidus <ieidus@redhat.com> Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, avi@redhat.com, aarcange@redhat.com, chrisw@redhat.com, riel@redhat.com, jeremy@goop.org, mtosatti@redhat.com, hugh@veritas.com, corbet@lwn.net, yaniv@redhat.com, dmonakhov@openvz.org, Izik Eidus <ieidus@redhat.com> Subject: [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages. Date: Tue, 31 Mar 2009 03:00:02 +0300 [thread overview] Message-ID: <1238457604-7637-2-git-send-email-ieidus@redhat.com> (raw) In-Reply-To: <1238457604-7637-1-git-send-email-ieidus@redhat.com> 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 <ieidus@redhat.com> --- 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 b625ed4..df8fbaf 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -567,9 +567,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], is_large_pte(*spte)); if (!*rmapp) { printk(KERN_ERR "rmap_remove: %p %llx 0->BUG\n", spte, *spte); @@ -1812,8 +1810,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte, page_header_update_slot(vcpu->kvm, shadow_pte, gfn); if (!was_rmapped) { rmap_add(vcpu, shadow_pte, gfn, largepage); - if (!is_rmap_pte(*shadow_pte)) - kvm_release_pfn_clean(pfn); + kvm_release_pfn_clean(pfn); } else { if (was_writeble) kvm_release_pfn_dirty(pfn); -- 1.5.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-03-31 0:02 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-03-31 0:00 [PATCH 0/3] kvm support for ksm Izik Eidus 2009-03-31 0:00 ` Izik Eidus 2009-03-31 0:00 ` Izik Eidus [this message] 2009-03-31 0:00 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Izik Eidus 2009-03-31 0:00 ` [PATCH 2/3] kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes Izik Eidus 2009-03-31 0:00 ` Izik Eidus 2009-03-31 0:00 ` [PATCH 3/3] kvm: add support for change_pte mmu notifiers Izik Eidus 2009-03-31 0:00 ` Izik Eidus 2009-04-09 9:59 ` [PATCH 2/3] kvm: add SPTE_HOST_WRITEABLE flag to the shadow ptes Marcelo Tosatti 2009-04-09 12:58 ` Izik Eidus 2009-04-09 9:54 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Marcelo Tosatti 2009-04-09 12:52 ` Izik Eidus 2009-04-12 9:01 ` Izik Eidus 2009-04-12 9:42 ` Avi Kivity 2022-10-18 3:19 ` [PATCH 0/3] kvm support for ksm ewandevelop 2022-10-18 3:31 ` ewandevelop 2009-09-10 16:38 [PATCH 0/3] ksm support for kvm Izik Eidus 2009-09-10 16:38 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Izik Eidus 2009-09-23 18:25 [PATCH 0/3] ksm support for kvm v2 Izik Eidus 2009-09-23 18:25 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Izik Eidus 2009-09-23 18:47 [PATCH 0/3] kvm ksm support v3 Izik Eidus 2009-09-23 18:47 ` [PATCH 1/3] kvm: dont hold pagecount reference for mapped sptes pages Izik Eidus 2009-09-24 14:18 ` Marcelo Tosatti 2009-09-24 16:56 ` Andrea Arcangeli
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=1238457604-7637-2-git-send-email-ieidus@redhat.com \ --to=ieidus@redhat.com \ --cc=aarcange@redhat.com \ --cc=avi@redhat.com \ --cc=chrisw@redhat.com \ --cc=corbet@lwn.net \ --cc=dmonakhov@openvz.org \ --cc=hugh@veritas.com \ --cc=jeremy@goop.org \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=mtosatti@redhat.com \ --cc=riel@redhat.com \ --cc=yaniv@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: linkBe 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.