[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Dynamic sizing of a domain's grant map tracking table on demand.



ChangeSet 1.1449, 2005/04/05 01:55:55+01:00, cwc22@xxxxxxxxxxxxxxxxxxxxxx

        Dynamic sizing of a domain's grant map tracking table on demand.
        Grant tables now default for block front/back communication.



 linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0 |    2 -
 linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU |    2 -
 linux-2.6.11-xen-sparse/arch/xen/Kconfig        |    5 +-
 xen/common/grant_table.c                        |   44 ++++++++++++++++++------
 xen/include/xen/grant_table.h                   |    3 +
 5 files changed, 39 insertions(+), 17 deletions(-)


diff -Nru a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0 
b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0
--- a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0   2005-04-05 04:04:03 
-04:00
+++ b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0   2005-04-05 04:04:03 
-04:00
@@ -16,7 +16,7 @@
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_NETDEV_FRONTEND=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
-# CONFIG_XEN_BLKDEV_GRANT is not set
+CONFIG_XEN_BLKDEV_GRANT=y
 # CONFIG_XEN_USB_FRONTEND is not set
 CONFIG_NO_IDLE_HZ=y
 CONFIG_FOREIGN_PAGES=y
diff -Nru a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU 
b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU
--- a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU   2005-04-05 04:04:03 
-04:00
+++ b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU   2005-04-05 04:04:03 
-04:00
@@ -15,7 +15,7 @@
 CONFIG_XEN_SCRUB_PAGES=y
 CONFIG_XEN_NETDEV_FRONTEND=y
 CONFIG_XEN_BLKDEV_FRONTEND=y
-# CONFIG_XEN_BLKDEV_GRANT is not set
+CONFIG_XEN_BLKDEV_GRANT=y
 # CONFIG_XEN_USB_FRONTEND is not set
 CONFIG_NO_IDLE_HZ=y
 # CONFIG_FOREIGN_PAGES is not set
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/Kconfig 
b/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- a/linux-2.6.11-xen-sparse/arch/xen/Kconfig  2005-04-05 04:04:03 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/Kconfig  2005-04-05 04:04:03 -04:00
@@ -64,12 +64,11 @@
 config XEN_BLKDEV_GRANT
         bool "Grant table substrate for block drivers (DANGEROUS)"
         depends on !XEN_BLKDEV_TAP_BE
-        default n
+        default y
         help
           This introduces the use of grant tables as a data exhange mechanism
           between the frontend and backend block drivers. This currently
-          conflicts with the block tap, and should be considered untested
-          and likely to render your system unstable.
+          conflicts with the block tap.
 
 config XEN_NETDEV_BACKEND
        bool "Network-device backend driver"
diff -Nru a/xen/common/grant_table.c b/xen/common/grant_table.c
--- a/xen/common/grant_table.c  2005-04-05 04:04:03 -04:00
+++ b/xen/common/grant_table.c  2005-04-05 04:04:03 -04:00
@@ -42,7 +42,7 @@
     grant_table_t *t)
 {
     unsigned int h;
-    if ( unlikely((h = t->maptrack_head) == NR_MAPTRACK_ENTRIES) )
+    if ( unlikely((h = t->maptrack_head) == t->maptrack_limit) )
         return -1;
     t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
     t->map_count++;
@@ -362,10 +362,30 @@
     /* get a maptrack handle */
     if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
     {
-        put_domain(rd);
-        DPRINTK("No more map handles available\n");
-        (void)__put_user(GNTST_no_device_space, &uop->handle);
-        return GNTST_no_device_space;
+        int              i;
+        grant_mapping_t *new_mt;
+        grant_table_t   *lgt      = ld->grant_table;
+
+        /* grow the maptrack table */
+        if ( (new_mt = (void *)alloc_xenheap_pages(lgt->maptrack_order + 1)) 
== NULL )
+        {
+            put_domain(rd);
+            DPRINTK("No more map handles available\n");
+            (void)__put_user(GNTST_no_device_space, &uop->handle);
+            return GNTST_no_device_space;
+        }
+
+        memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
+        for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
+            new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+
+        free_xenheap_pages((unsigned long)lgt->maptrack, lgt->maptrack_order);
+        lgt->maptrack          = new_mt;
+        lgt->maptrack_order   += 1;
+        lgt->maptrack_limit  <<= 1;
+
+        printk("Doubled maptrack size\n");
+        handle = get_maptrack_handle(ld->grant_table);
     }
 
 #ifdef GRANT_DEBUG_VERBOSE
@@ -458,7 +478,7 @@
 
     map = &ld->grant_table->maptrack[handle];
 
-    if ( unlikely(handle >= NR_MAPTRACK_ENTRIES) ||
+    if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
          unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
     {
         DPRINTK("Bad handle (%d).\n", handle);
@@ -752,7 +772,7 @@
         }
     }
 
-    for ( i = 0; i < NR_MAPTRACK_ENTRIES; i++ )
+    for ( i = 0; i < gt->maptrack_limit; i++ )
     {
         maptrack = &gt->maptrack[i];
 
@@ -860,7 +880,7 @@
 
     rgt = rd->grant_table;
 
-    for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
+    for ( handle = 0; handle < lgt->maptrack_limit; handle++ )
     {
         map = &lgt->maptrack[handle];
 
@@ -1074,8 +1094,10 @@
     /* Tracking of mapped foreign frames table */
     if ( (t->maptrack = (void *)alloc_xenheap_page()) == NULL )
         goto no_mem;
+    t->maptrack_order = 0;
+    t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
     memset(t->maptrack, 0, PAGE_SIZE);
-    for ( i = 0; i < NR_MAPTRACK_ENTRIES; i++ )
+    for ( i = 0; i < t->maptrack_limit; i++ )
         t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
 
     /* Shared grant table. */
@@ -1121,7 +1143,7 @@
 
     ld = current->domain;
 
-    for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
+    for ( handle = 0; handle < gt->maptrack_limit; handle++ )
     {
         map = &gt->maptrack[handle];
 
@@ -1191,7 +1213,7 @@
         /* Free memory relating to this grant table. */
         d->grant_table = NULL;
         free_xenheap_pages((unsigned long)t->shared, ORDER_GRANT_FRAMES);
-        free_xenheap_page((unsigned long)t->maptrack);
+        free_xenheap_page((unsigned long)t->maptrack); //cwc22
         xfree(t->active);
         xfree(t);
     }
diff -Nru a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h     2005-04-05 04:04:03 -04:00
+++ b/xen/include/xen/grant_table.h     2005-04-05 04:04:03 -04:00
@@ -66,7 +66,6 @@
 } grant_mapping_t;
 #define MAPTRACK_GNTMAP_MASK 7
 #define MAPTRACK_REF_SHIFT   3
-#define NR_MAPTRACK_ENTRIES  (PAGE_SIZE / sizeof(grant_mapping_t))
 
 /* Per-domain grant information. */
 typedef struct {
@@ -77,6 +76,8 @@
     /* Mapping tracking table. */
     grant_mapping_t      *maptrack;
     unsigned int          maptrack_head;
+    unsigned int          maptrack_order;
+    unsigned int          maptrack_limit;
     unsigned int          map_count;
     /* Lock protecting updates to active and shared grant tables. */
     spinlock_t            lock;

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.