direct-io.hg

changeset 4463:20cefa5670dd

bitkeeper revision 1.1236.1.213 (4251e21boiMcVvsOm7kHtd1O51o1mA)

Dynamic sizing of a domain's grant map tracking table on demand.
Grant tables now default for block front/back communication.
author cwc22@centipede.cl.cam.ac.uk
date Tue Apr 05 00:55:55 2005 +0000 (2005-04-05)
parents eb31fbbaa355
children 7fc6eac6da3a cedeb2bbe015
files linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0 linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU linux-2.6.11-xen-sparse/arch/xen/Kconfig xen/common/grant_table.c xen/include/xen/grant_table.h
line diff
     1.1 --- a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0	Mon Apr 04 20:25:30 2005 +0000
     1.2 +++ b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xen0	Tue Apr 05 00:55:55 2005 +0000
     1.3 @@ -16,7 +16,7 @@ CONFIG_XEN_PHYSDEV_ACCESS=y
     1.4  CONFIG_XEN_SCRUB_PAGES=y
     1.5  CONFIG_XEN_NETDEV_FRONTEND=y
     1.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     1.7 -# CONFIG_XEN_BLKDEV_GRANT is not set
     1.8 +CONFIG_XEN_BLKDEV_GRANT=y
     1.9  # CONFIG_XEN_USB_FRONTEND is not set
    1.10  CONFIG_NO_IDLE_HZ=y
    1.11  CONFIG_FOREIGN_PAGES=y
     2.1 --- a/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU	Mon Apr 04 20:25:30 2005 +0000
     2.2 +++ b/linux-2.4.29-xen-sparse/arch/xen/defconfig-xenU	Tue Apr 05 00:55:55 2005 +0000
     2.3 @@ -15,7 +15,7 @@ CONFIG_UID16=y
     2.4  CONFIG_XEN_SCRUB_PAGES=y
     2.5  CONFIG_XEN_NETDEV_FRONTEND=y
     2.6  CONFIG_XEN_BLKDEV_FRONTEND=y
     2.7 -# CONFIG_XEN_BLKDEV_GRANT is not set
     2.8 +CONFIG_XEN_BLKDEV_GRANT=y
     2.9  # CONFIG_XEN_USB_FRONTEND is not set
    2.10  CONFIG_NO_IDLE_HZ=y
    2.11  # CONFIG_FOREIGN_PAGES is not set
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/Kconfig	Mon Apr 04 20:25:30 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/Kconfig	Tue Apr 05 00:55:55 2005 +0000
     3.3 @@ -64,12 +64,11 @@ config XEN_BLKDEV_TAP_BE
     3.4  config XEN_BLKDEV_GRANT
     3.5          bool "Grant table substrate for block drivers (DANGEROUS)"
     3.6          depends on !XEN_BLKDEV_TAP_BE
     3.7 -        default n
     3.8 +        default y
     3.9          help
    3.10            This introduces the use of grant tables as a data exhange mechanism
    3.11            between the frontend and backend block drivers. This currently
    3.12 -          conflicts with the block tap, and should be considered untested
    3.13 -          and likely to render your system unstable.
    3.14 +          conflicts with the block tap.
    3.15  
    3.16  config XEN_NETDEV_BACKEND
    3.17  	bool "Network-device backend driver"
     4.1 --- a/xen/common/grant_table.c	Mon Apr 04 20:25:30 2005 +0000
     4.2 +++ b/xen/common/grant_table.c	Tue Apr 05 00:55:55 2005 +0000
     4.3 @@ -42,7 +42,7 @@ get_maptrack_handle(
     4.4      grant_table_t *t)
     4.5  {
     4.6      unsigned int h;
     4.7 -    if ( unlikely((h = t->maptrack_head) == NR_MAPTRACK_ENTRIES) )
     4.8 +    if ( unlikely((h = t->maptrack_head) == t->maptrack_limit) )
     4.9          return -1;
    4.10      t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
    4.11      t->map_count++;
    4.12 @@ -362,10 +362,30 @@ 0) )
    4.13      /* get a maptrack handle */
    4.14      if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
    4.15      {
    4.16 -        put_domain(rd);
    4.17 -        DPRINTK("No more map handles available\n");
    4.18 -        (void)__put_user(GNTST_no_device_space, &uop->handle);
    4.19 -        return GNTST_no_device_space;
    4.20 +        int              i;
    4.21 +        grant_mapping_t *new_mt;
    4.22 +        grant_table_t   *lgt      = ld->grant_table;
    4.23 +
    4.24 +        /* grow the maptrack table */
    4.25 +        if ( (new_mt = (void *)alloc_xenheap_pages(lgt->maptrack_order + 1)) == NULL )
    4.26 +        {
    4.27 +            put_domain(rd);
    4.28 +            DPRINTK("No more map handles available\n");
    4.29 +            (void)__put_user(GNTST_no_device_space, &uop->handle);
    4.30 +            return GNTST_no_device_space;
    4.31 +        }
    4.32 +
    4.33 +        memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
    4.34 +        for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
    4.35 +            new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
    4.36 +
    4.37 +        free_xenheap_pages((unsigned long)lgt->maptrack, lgt->maptrack_order);
    4.38 +        lgt->maptrack          = new_mt;
    4.39 +        lgt->maptrack_order   += 1;
    4.40 +        lgt->maptrack_limit  <<= 1;
    4.41 +
    4.42 +        printk("Doubled maptrack size\n");
    4.43 +        handle = get_maptrack_handle(ld->grant_table);
    4.44      }
    4.45  
    4.46  #ifdef GRANT_DEBUG_VERBOSE
    4.47 @@ -458,7 +478,7 @@ static int
    4.48  
    4.49      map = &ld->grant_table->maptrack[handle];
    4.50  
    4.51 -    if ( unlikely(handle >= NR_MAPTRACK_ENTRIES) ||
    4.52 +    if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
    4.53           unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
    4.54      {
    4.55          DPRINTK("Bad handle (%d).\n", handle);
    4.56 @@ -752,7 +772,7 @@ gnttab_dump_table(gnttab_dump_table_t *u
    4.57          }
    4.58      }
    4.59  
    4.60 -    for ( i = 0; i < NR_MAPTRACK_ENTRIES; i++ )
    4.61 +    for ( i = 0; i < gt->maptrack_limit; i++ )
    4.62      {
    4.63          maptrack = &gt->maptrack[i];
    4.64  
    4.65 @@ -860,7 +880,7 @@ gnttab_check_unmap(
    4.66  
    4.67      rgt = rd->grant_table;
    4.68  
    4.69 -    for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
    4.70 +    for ( handle = 0; handle < lgt->maptrack_limit; handle++ )
    4.71      {
    4.72          map = &lgt->maptrack[handle];
    4.73  
    4.74 @@ -1074,8 +1094,10 @@ grant_table_create(
    4.75      /* Tracking of mapped foreign frames table */
    4.76      if ( (t->maptrack = (void *)alloc_xenheap_page()) == NULL )
    4.77          goto no_mem;
    4.78 +    t->maptrack_order = 0;
    4.79 +    t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
    4.80      memset(t->maptrack, 0, PAGE_SIZE);
    4.81 -    for ( i = 0; i < NR_MAPTRACK_ENTRIES; i++ )
    4.82 +    for ( i = 0; i < t->maptrack_limit; i++ )
    4.83          t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
    4.84  
    4.85      /* Shared grant table. */
    4.86 @@ -1121,7 +1143,7 @@ gnttab_release_dev_mappings(grant_table_
    4.87  
    4.88      ld = current->domain;
    4.89  
    4.90 -    for ( handle = 0; handle < NR_MAPTRACK_ENTRIES; handle++ )
    4.91 +    for ( handle = 0; handle < gt->maptrack_limit; handle++ )
    4.92      {
    4.93          map = &gt->maptrack[handle];
    4.94  
    4.95 @@ -1191,7 +1213,7 @@ grant_table_destroy(
    4.96          /* Free memory relating to this grant table. */
    4.97          d->grant_table = NULL;
    4.98          free_xenheap_pages((unsigned long)t->shared, ORDER_GRANT_FRAMES);
    4.99 -        free_xenheap_page((unsigned long)t->maptrack);
   4.100 +        free_xenheap_page((unsigned long)t->maptrack); //cwc22
   4.101          xfree(t->active);
   4.102          xfree(t);
   4.103      }
     5.1 --- a/xen/include/xen/grant_table.h	Mon Apr 04 20:25:30 2005 +0000
     5.2 +++ b/xen/include/xen/grant_table.h	Tue Apr 05 00:55:55 2005 +0000
     5.3 @@ -66,7 +66,6 @@ typedef struct {
     5.4  } grant_mapping_t;
     5.5  #define MAPTRACK_GNTMAP_MASK 7
     5.6  #define MAPTRACK_REF_SHIFT   3
     5.7 -#define NR_MAPTRACK_ENTRIES  (PAGE_SIZE / sizeof(grant_mapping_t))
     5.8  
     5.9  /* Per-domain grant information. */
    5.10  typedef struct {
    5.11 @@ -77,6 +76,8 @@ typedef struct {
    5.12      /* Mapping tracking table. */
    5.13      grant_mapping_t      *maptrack;
    5.14      unsigned int          maptrack_head;
    5.15 +    unsigned int          maptrack_order;
    5.16 +    unsigned int          maptrack_limit;
    5.17      unsigned int          map_count;
    5.18      /* Lock protecting updates to active and shared grant tables. */
    5.19      spinlock_t            lock;