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

RE: [Xen-devel] slow xp hibernation revisited

To: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>, "Stefano Stabellini" <stefano.stabellini@xxxxxxxxxxxxx>
Subject: RE: [Xen-devel] slow xp hibernation revisited
From: "James Harper" <james.harper@xxxxxxxxxxxxxxxx>
Date: Mon, 6 Jun 2011 23:29:18 +1000
Cc: Tim Deegan <Tim.Deegan@xxxxxxxxxxxxx>, Keir Fraser <keir.xen@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 06 Jun 2011 06:32:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <AEC6C66638C05B468B556EA548C1A77D01D5780D@trantor>
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>
References: <AEC6C66638C05B468B556EA548C1A77D01D57760@trantor><CA0FA2A9.1B9B2%keir.xen@xxxxxxxxx><AEC6C66638C05B468B556EA548C1A77D01D57761@trantor><alpine.DEB.2.00.1106061150320.12963@kaball-desktop> <AEC6C66638C05B468B556EA548C1A77D01D5780D@trantor>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcwkSpquoFopxSF3TBGH2JvjsPxajgAAES5wAACvB+A=
Thread-topic: [Xen-devel] slow xp hibernation revisited
> > This is just a matter of aesthetic, but probably something like the
> > following would be clearer?
> >
> > if (entry->vaddr_base && entry->paddr_index == address_index) {
> >     if (!test_bit(address_offset>>XC_PAGE_SHIFT,
> entry->valid_mapping)) {
> >             /* your code + remap bucket */
> >     }
> > } else {
> >     qemu_remap_bucket(entry, address_index);
> > }
> >
> 
> Yes that should work, although I think I'm too tired now for Boolean
> algebra :)
> 
> Is my calculation of the pfn correct? I think I don't need to fuss
> around with decoding from the bucket index and bucket offset if I'm
just
> doing a trial map of one page, so using phys_addr directory is correct
> right?
> 

Is this what you had in mind?

diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index d02e23f..3c9fc0f 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -151,8 +151,30 @@ uint8_t *qemu_map_cache(target_phys_addr_t
phys_addr, uint8_t lock)
         pentry->next = entry;
         qemu_remap_bucket(entry, address_index);
     } else if (!entry->lock) {
-        if (!entry->vaddr_base || entry->paddr_index != address_index
|| !test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping))
+        if (entry->vaddr_base && entry->paddr_index == address_index)
+        {
+            if (!test_bit(address_offset>>XC_PAGE_SHIFT,
entry->valid_mapping))
+            {
+                /* The page was invalid previously. Test if it is valid
now and only remap if so */
+                xen_pfn_t pfn;
+                int err;
+                void *tmp_vaddr;
+
+                pfn = phys_addr >> XC_PAGE_SHIFT;
+                tmp_vaddr = xc_map_foreign_bulk(xc_handle, domid,
PROT_READ|PROT_WRITE, &pfn, &err, 1);
+                if (tmp_vaddr)
+                    munmap(tmp_vaddr, PAGE_SIZE);
+
+                if (!tmp_vaddr || err)
+                {
+                    last_address_index = ~0UL;
+                    return NULL;
+                }
+                qemu_remap_bucket(entry, address_index);
+            }
+        } else {
             qemu_remap_bucket(entry, address_index);
+        }
     }

     if (!test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping))
{

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