[PATCH 25 of 25] kvm mmu transparent hugepage support

Andrea Arcangeli
2009-11-14T18:10:24Z

Cc: kvm@vger.kernel.org
From: Marcelo Tosatti <mtosatti@redhat.com>

This should work for both hugetlbfs and transparent hugepages.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -489,6 +489,15 @@ static int host_mapping_level(struct kvm
out:
up_read(&current->mm->mmap_sem);

+ /* check for transparent hugepages */
+ if (page_size == PAGE_SIZE) {
+ struct page *page = gfn_to_page(kvm, gfn);
+
+ if (!is_error_page(page) && PageHead(page))
+ page_size = KVM_HPAGE_SIZE(2);
+ kvm_release_page_clean(page);
+ }
+
for (i = PT_PAGE_TABLE_LEVEL;
i < (PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES); ++i) {
if (page_size >= KVM_HPAGE_SIZE(i))