From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] mapcache fixes
Date: Thu, 09 Apr 2009 11:35:46 +0100 [thread overview]
Message-ID: <49DDCF82.70504@eu.citrix.com> (raw)
Hi all,
this patch makes the new mapcache code cleaner and fixes few problems
introduced by the recent mapcache improvements.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index cbd32c7..b01605b 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -173,15 +173,13 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, uint8_t lock)
void qemu_invalidate_entry(uint8_t *buffer)
{
- struct map_cache *entry = NULL, *next;
+ struct map_cache *entry = NULL, *pentry = NULL;
struct map_cache_rev *reventry;
unsigned long paddr_index;
int found = 0;
- if (last_address_vaddr == buffer) {
+ if (last_address_vaddr == buffer)
last_address_index = ~0UL;
- last_address_vaddr = NULL;
- }
TAILQ_FOREACH(reventry, &locked_entries, next) {
if (reventry->vaddr_req == buffer) {
@@ -200,26 +198,26 @@ void qemu_invalidate_entry(uint8_t *buffer)
TAILQ_REMOVE(&locked_entries, reventry, next);
qemu_free(reventry);
- next = &mapcache_entry[paddr_index];
- if (next->paddr_index == paddr_index) {
- next->lock--;
+ entry = &mapcache_entry[paddr_index % nr_buckets];
+ while (entry && entry->paddr_index != paddr_index) {
+ pentry = entry;
+ entry = entry->next;
+ }
+ if (!entry) {
+ fprintf(logfile, "Trying to unmap address %p that is not in the mapcache!\n", buffer);
return;
}
+ entry->lock--;
+ if (entry->lock > 0 || pentry == NULL)
+ return;
- while (next != NULL && next->paddr_index != paddr_index) {
- entry = next;
- next = next->next;
- }
- if (!next)
- fprintf(logfile, "Trying to unmap address %p that is not in the mapcache!\n", buffer);
-
- entry->next = next->next;
- errno = munmap(next->vaddr_base, MCACHE_BUCKET_SIZE);
+ pentry->next = entry->next;
+ errno = munmap(entry->vaddr_base, MCACHE_BUCKET_SIZE);
if (errno) {
fprintf(logfile, "unmap fails %d\n", errno);
exit(-1);
}
- qemu_free(next);
+ qemu_free(entry);
}
void qemu_invalidate_map_cache(void)
diff --git a/i386-dm/exec-dm.c b/i386-dm/exec-dm.c
index a509fc5..dbf03a8 100644
--- a/i386-dm/exec-dm.c
+++ b/i386-dm/exec-dm.c
@@ -801,4 +801,5 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
int is_write, target_phys_addr_t access_len)
{
qemu_invalidate_entry(buffer);
+ cpu_notify_map_clients();
}
reply other threads:[~2009-04-09 10:35 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=49DDCF82.70504@eu.citrix.com \
--to=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.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 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.