From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: qemu-devel@nongnu.org
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
hanweidong@huawei.com, arei.gonglei@huawei.com,
yanqiangjun@huawei.com, xen-devel@lists.xen.org
Subject: [Qemu-devel] [PATCH 1/2] xen-mapcache: replace last_address_index with a last_entry pointer
Date: Tue, 2 Apr 2013 14:25:21 +0100 [thread overview]
Message-ID: <1364909122-4556-1-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
Replace last_address_index and last_address_vaddr with a single pointer
to the last MapCacheEntry used.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
xen-mapcache.c | 34 ++++++++++++++++------------------
1 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/xen-mapcache.c b/xen-mapcache.c
index dc6d1fa..a80cbdb 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -74,8 +74,7 @@ typedef struct MapCache {
QTAILQ_HEAD(map_cache_head, MapCacheRev) locked_entries;
/* For most cases (>99.9%), the page address is the same. */
- hwaddr last_address_index;
- uint8_t *last_address_vaddr;
+ MapCacheEntry *last_entry;
unsigned long max_mcache_size;
unsigned int mcache_bucket_shift;
@@ -105,7 +104,6 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque)
mapcache->opaque = opaque;
QTAILQ_INIT(&mapcache->locked_entries);
- mapcache->last_address_index = -1;
if (geteuid() == 0) {
rlimit_as.rlim_cur = RLIM_INFINITY;
@@ -210,9 +208,11 @@ tryagain:
trace_xen_map_cache(phys_addr);
- if (address_index == mapcache->last_address_index && !lock && !__size) {
- trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);
- return mapcache->last_address_vaddr + address_offset;
+ if (mapcache->last_entry != NULL &&
+ mapcache->last_entry->paddr_index == address_index &&
+ !lock && !__size) {
+ trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);
+ return mapcache->last_entry->vaddr_base + address_offset;
}
/* size is always a multiple of MCACHE_BUCKET_SIZE */
@@ -249,7 +249,7 @@ tryagain:
if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,
entry->valid_mapping)) {
- mapcache->last_address_index = -1;
+ mapcache->last_entry = NULL;
if (!translated && mapcache->phys_offset_to_gaddr) {
phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque);
translated = true;
@@ -259,19 +259,18 @@ tryagain:
return NULL;
}
- mapcache->last_address_index = address_index;
- mapcache->last_address_vaddr = entry->vaddr_base;
+ mapcache->last_entry = entry;
if (lock) {
MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));
entry->lock++;
- reventry->vaddr_req = mapcache->last_address_vaddr + address_offset;
- reventry->paddr_index = mapcache->last_address_index;
+ reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset;
+ reventry->paddr_index = mapcache->last_entry->paddr_index;
reventry->size = entry->size;
QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);
}
- trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);
- return mapcache->last_address_vaddr + address_offset;
+ trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset);
+ return mapcache->last_entry->vaddr_base + address_offset;
}
ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
@@ -338,9 +337,9 @@ void xen_invalidate_map_cache_entry(uint8_t *buffer)
QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
g_free(reventry);
- if (mapcache->last_address_index == paddr_index) {
- mapcache->last_address_index = -1;
- mapcache->last_address_vaddr = NULL;
+ if (mapcache->last_entry != NULL &&
+ mapcache->last_entry->paddr_index == paddr_index) {
+ mapcache->last_entry = NULL;
}
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
@@ -404,8 +403,7 @@ void xen_invalidate_map_cache(void)
entry->valid_mapping = NULL;
}
- mapcache->last_address_index = -1;
- mapcache->last_address_vaddr = NULL;
+ mapcache->last_entry = NULL;
mapcache_unlock();
}
--
1.7.2.5
reply other threads:[~2013-04-02 13:25 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=1364909122-4556-1-git-send-email-stefano.stabellini@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=arei.gonglei@huawei.com \
--cc=hanweidong@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=xen-devel@lists.xen.org \
--cc=yanqiangjun@huawei.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: 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;
as well as URLs for NNTP newsgroup(s).