lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1185173508.2645.72.camel@sli10-conroe.sh.intel.com>
Date:	Mon, 23 Jul 2007 14:51:48 +0800
From:	Shaohua Li <shaohua.li@...el.com>
To:	kvm-devel <kvm-devel@...ts.sourceforge.net>,
	lkml <linux-kernel@...r.kernel.org>
Cc:	Avi Kivity <avi@...ranet.com>, Ingo Molnar <mingo@...e.hu>
Subject: [RFC 8/8]KVM: cache pages

KVM use gfn_to_page very frequestly, which makes find_get_page a bottleneck,
so cache pages found to speed up.

Signed-off-by: Shaohua Li <shaohua.li@...el.com>
---
 drivers/kvm/kvm.h      |    1 +
 drivers/kvm/kvm_main.c |    9 +++++++++
 2 files changed, 10 insertions(+)

Index: linux/drivers/kvm/kvm.h
===================================================================
--- linux.orig/drivers/kvm/kvm.h	2007-07-20 14:29:46.000000000 +0800
+++ linux/drivers/kvm/kvm.h	2007-07-20 14:50:11.000000000 +0800
@@ -431,6 +431,7 @@ struct kvm_mem_alias {
 
 struct kvm_page_info {
 	swp_entry_t entry;
+	struct page *page;
 };
 
 struct kvm_memory_slot {
Index: linux/drivers/kvm/kvm_main.c
===================================================================
--- linux.orig/drivers/kvm/kvm_main.c	2007-07-20 14:45:40.000000000 +0800
+++ linux/drivers/kvm/kvm_main.c	2007-07-20 14:50:11.000000000 +0800
@@ -1031,6 +1031,7 @@ repeat:
 		info->entry.val = 0;
 		if (add_to_page_cache(page, mapping, gfn, GFP_KERNEL))
 			return NULL;
+		info->page = page;
 		ClearPageDirty(page);
 	} else {
 		/* allocate new page */
@@ -1041,6 +1042,7 @@ repeat:
 			page_cache_release(page);
 			return NULL;
 		}
+		info->page = page;
 		SetPageUptodate(page);
 		set_page_private(page, 0);
 	}
@@ -1063,6 +1065,7 @@ static int kvm_move_to_swap(struct page 
 	if (move_to_swap_cache(page, swap) == 0) {
 		slot = __gfn_to_memslot(kvm, gfn);
 		slot->phys_mem[gfn - slot->base_gfn].entry = swap;
+		slot->phys_mem[gfn - slot->base_gfn].page = NULL;
 		return 0;
 	}
 	swap_free(swap);
@@ -1082,6 +1085,12 @@ struct page *gfn_to_page(struct kvm *kvm
 	if (!slot)
 		return NULL;
 
+	page = slot->phys_mem[gfn - slot->base_gfn].page;
+	if (page) {
+		mark_page_accessed(page);
+		return page;
+	}
+
 	page = find_get_page(mapping, gfn);
 	if (page)
 		goto out;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ