WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] mapcache fixes

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] mapcache fixes
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 09 Apr 2009 11:35:46 +0100
Delivery-date: Thu, 09 Apr 2009 03:35:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080505)
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@xxxxxxxxxxxxx>

---

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();
 }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] mapcache fixes, Stefano Stabellini <=