mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: kvm-devel <kvm-devel@lists.sourceforge.net>,
	lkml <linux-kernel@vger.kernel.org>
Cc: Avi Kivity <avi@qumranet.com>, Ingo Molnar <mingo@elte.hu>
Subject: [RFC 8/8]KVM: cache pages
Date: Mon, 23 Jul 2007 14:51:48 +0800	[thread overview]
Message-ID: <1185173508.2645.72.camel@sli10-conroe.sh.intel.com> (raw)

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@intel.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;

                 reply	other threads:[~2007-07-23  7:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1185173508.2645.72.camel@sli10-conroe.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=avi@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®