direct-io.hg

changeset 9653:b055716f89c0

Replace grant-table typedefs with explicit structs.
Reduce MAPTRACK_MAX_ENTRIES to something plausible.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 14 14:54:46 2006 +0100 (2006-04-14)
parents 5c477ad95dba
children b36a43b9d9b5
files xen/arch/x86/audit.c xen/common/grant_table.c xen/include/xen/grant_table.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/x86/audit.c	Fri Apr 14 14:40:30 2006 +0100
     1.2 +++ b/xen/arch/x86/audit.c	Fri Apr 14 14:54:46 2006 +0100
     1.3 @@ -639,7 +639,7 @@ void _audit_domain(struct domain *d, int
     1.4      void scan_for_pfn_in_grant_table(struct domain *d, unsigned xmfn)
     1.5      {
     1.6          int i;
     1.7 -        active_grant_entry_t *act = d->grant_table->active;
     1.8 +        struct active_grant_entry *act = d->grant_table->active;
     1.9  
    1.10          spin_lock(&d->grant_table->lock);
    1.11  
     2.1 --- a/xen/common/grant_table.c	Fri Apr 14 14:40:30 2006 +0100
     2.2 +++ b/xen/common/grant_table.c	Fri Apr 14 14:54:46 2006 +0100
     2.3 @@ -41,7 +41,7 @@
     2.4  
     2.5  static inline int
     2.6  get_maptrack_handle(
     2.7 -    grant_table_t *t)
     2.8 +    struct grant_table *t)
     2.9  {
    2.10      unsigned int h;
    2.11      if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
    2.12 @@ -53,7 +53,7 @@ get_maptrack_handle(
    2.13  
    2.14  static inline void
    2.15  put_maptrack_handle(
    2.16 -    grant_table_t *t, int handle)
    2.17 +    struct grant_table *t, int handle)
    2.18  {
    2.19      t->maptrack[handle].ref = t->maptrack_head;
    2.20      t->maptrack_head = handle;
    2.21 @@ -76,7 +76,7 @@ static void
    2.22      int            handle;
    2.23      unsigned long  frame = 0;
    2.24      int            rc = GNTST_okay;
    2.25 -    active_grant_entry_t *act;
    2.26 +    struct active_grant_entry *act;
    2.27  
    2.28      /* Entry details from @rd's shared grant table. */
    2.29      grant_entry_t *sha;
    2.30 @@ -123,9 +123,9 @@ static void
    2.31      /* Get a maptrack handle. */
    2.32      if ( unlikely((handle = get_maptrack_handle(ld->grant_table)) == -1) )
    2.33      {
    2.34 -        int              i;
    2.35 -        grant_mapping_t *new_mt;
    2.36 -        grant_table_t   *lgt = ld->grant_table;
    2.37 +        int                   i;
    2.38 +        struct grant_mapping *new_mt;
    2.39 +        struct grant_table   *lgt = ld->grant_table;
    2.40  
    2.41          if ( (lgt->maptrack_limit << 1) > MAPTRACK_MAX_ENTRIES )
    2.42          {
    2.43 @@ -264,10 +264,9 @@ static void
    2.44  
    2.45      TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, op->dom);
    2.46  
    2.47 -    ld->grant_table->maptrack[handle].domid         = op->dom;
    2.48 -    ld->grant_table->maptrack[handle].ref = op->ref;
    2.49 -    ld->grant_table->maptrack[handle].flags =
    2.50 -        (op->flags & MAPTRACK_GNTMAP_MASK);
    2.51 +    ld->grant_table->maptrack[handle].domid = op->dom;
    2.52 +    ld->grant_table->maptrack[handle].ref   = op->ref;
    2.53 +    ld->grant_table->maptrack[handle].flags = op->flags;
    2.54  
    2.55      op->dev_bus_addr = (u64)frame << PAGE_SHIFT;
    2.56      op->handle       = handle;
    2.57 @@ -326,9 +325,9 @@ static void
    2.58      domid_t          dom;
    2.59      grant_ref_t      ref;
    2.60      struct domain   *ld, *rd;
    2.61 -    active_grant_entry_t *act;
    2.62 +    struct active_grant_entry *act;
    2.63      grant_entry_t   *sha;
    2.64 -    grant_mapping_t *map;
    2.65 +    struct grant_mapping *map;
    2.66      u16              flags;
    2.67      s16              rc = 0;
    2.68      unsigned long    frame;
    2.69 @@ -534,12 +533,12 @@ static int
    2.70  gnttab_prepare_for_transfer(
    2.71      struct domain *rd, struct domain *ld, grant_ref_t ref)
    2.72  {
    2.73 -    grant_table_t *rgt;
    2.74 -    grant_entry_t *sha;
    2.75 -    domid_t        sdom;
    2.76 -    u16            sflags;
    2.77 -    u32            scombo, prev_scombo;
    2.78 -    int            retries = 0;
    2.79 +    struct grant_table *rgt;
    2.80 +    struct grant_entry *sha;
    2.81 +    domid_t             sdom;
    2.82 +    u16                 sflags;
    2.83 +    u32                 scombo, prev_scombo;
    2.84 +    int                 retries = 0;
    2.85  
    2.86      if ( unlikely((rgt = rd->grant_table) == NULL) ||
    2.87           unlikely(ref >= NR_GRANT_ENTRIES) )
    2.88 @@ -775,11 +774,11 @@ int
    2.89  grant_table_create(
    2.90      struct domain *d)
    2.91  {
    2.92 -    grant_table_t *t;
    2.93 -    int            i;
    2.94 +    struct grant_table *t;
    2.95 +    int                 i;
    2.96  
    2.97      BUG_ON(MAPTRACK_MAX_ENTRIES < NR_GRANT_ENTRIES);
    2.98 -    if ( (t = xmalloc(grant_table_t)) == NULL )
    2.99 +    if ( (t = xmalloc(struct grant_table)) == NULL )
   2.100          goto no_mem;
   2.101  
   2.102      /* Simple stuff. */
   2.103 @@ -787,16 +786,16 @@ grant_table_create(
   2.104      spin_lock_init(&t->lock);
   2.105  
   2.106      /* Active grant table. */
   2.107 -    if ( (t->active = xmalloc_array(active_grant_entry_t, NR_GRANT_ENTRIES))
   2.108 -         == NULL )
   2.109 +    t->active = xmalloc_array(struct active_grant_entry, NR_GRANT_ENTRIES);
   2.110 +    if ( t->active == NULL )
   2.111          goto no_mem;
   2.112 -    memset(t->active, 0, sizeof(active_grant_entry_t) * NR_GRANT_ENTRIES);
   2.113 +    memset(t->active, 0, sizeof(struct active_grant_entry) * NR_GRANT_ENTRIES);
   2.114  
   2.115      /* Tracking of mapped foreign frames table */
   2.116      if ( (t->maptrack = alloc_xenheap_page()) == NULL )
   2.117          goto no_mem;
   2.118      t->maptrack_order = 0;
   2.119 -    t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
   2.120 +    t->maptrack_limit = PAGE_SIZE / sizeof(struct grant_mapping);
   2.121      memset(t->maptrack, 0, PAGE_SIZE);
   2.122      for ( i = 0; i < t->maptrack_limit; i++ )
   2.123          t->maptrack[i].ref = i+1;
   2.124 @@ -829,13 +828,13 @@ void
   2.125  gnttab_release_mappings(
   2.126      struct domain *d)
   2.127  {
   2.128 -    grant_table_t        *gt = d->grant_table;
   2.129 -    grant_mapping_t      *map;
   2.130 +    struct grant_table   *gt = d->grant_table;
   2.131 +    struct grant_mapping *map;
   2.132      grant_ref_t           ref;
   2.133      grant_handle_t        handle;
   2.134      struct domain        *rd;
   2.135 -    active_grant_entry_t *act;
   2.136 -    grant_entry_t        *sha;
   2.137 +    struct active_grant_entry *act;
   2.138 +    struct grant_entry   *sha;
   2.139  
   2.140      BUG_ON(!test_bit(_DOMF_dying, &d->domain_flags));
   2.141  
   2.142 @@ -912,7 +911,7 @@ void
   2.143  grant_table_destroy(
   2.144      struct domain *d)
   2.145  {
   2.146 -    grant_table_t *t = d->grant_table;
   2.147 +    struct grant_table *t = d->grant_table;
   2.148  
   2.149      if ( t == NULL )
   2.150          return;
     3.1 --- a/xen/include/xen/grant_table.h	Fri Apr 14 14:40:30 2006 +0100
     3.2 +++ b/xen/include/xen/grant_table.h	Fri Apr 14 14:54:46 2006 +0100
     3.3 @@ -29,11 +29,11 @@
     3.4  #include <asm/grant_table.h>
     3.5  
     3.6  /* Active grant entry - used for shadowing GTF_permit_access grants. */
     3.7 -typedef struct {
     3.8 +struct active_grant_entry {
     3.9      u32           pin;    /* Reference count information.  */
    3.10      domid_t       domid;  /* Domain being granted access.  */
    3.11      unsigned long frame;  /* Frame being granted.          */
    3.12 -} active_grant_entry_t;
    3.13 +};
    3.14  
    3.15   /* Count of writable host-CPU mappings. */
    3.16  #define GNTPIN_hstw_shift    (0)
    3.17 @@ -60,29 +60,30 @@ typedef struct {
    3.18   * Tracks a mapping of another domain's grant reference. Each domain has a
    3.19   * table of these, indexes into which are returned as a 'mapping handle'.
    3.20   */
    3.21 -typedef struct {
    3.22 +struct grant_mapping {
    3.23      u32      ref;           /* grant ref */
    3.24      u16      flags;         /* 0-4: GNTMAP_* ; 5-15: unused */
    3.25      domid_t  domid;         /* granting domain */
    3.26 -} grant_mapping_t;
    3.27 -#define MAPTRACK_GNTMAP_MASK  0x1f
    3.28 -#define MAPTRACK_MAX_ENTRIES  (~((u32)0))
    3.29 +};
    3.30 +
    3.31 +/* Fairly arbitrary. [POLICY] */
    3.32 +#define MAPTRACK_MAX_ENTRIES 16384
    3.33  
    3.34  /* Per-domain grant information. */
    3.35 -typedef struct {
    3.36 +struct grant_table {
    3.37      /* Shared grant table (see include/public/grant_table.h). */
    3.38 -    grant_entry_t        *shared;
    3.39 +    struct grant_entry   *shared;
    3.40      /* Active grant table. */
    3.41 -    active_grant_entry_t *active;
    3.42 +    struct active_grant_entry *active;
    3.43      /* Mapping tracking table. */
    3.44 -    grant_mapping_t      *maptrack;
    3.45 +    struct grant_mapping *maptrack;
    3.46      unsigned int          maptrack_head;
    3.47      unsigned int          maptrack_order;
    3.48      unsigned int          maptrack_limit;
    3.49      unsigned int          map_count;
    3.50      /* Lock protecting updates to active and shared grant tables. */
    3.51      spinlock_t            lock;
    3.52 -} grant_table_t;
    3.53 +};
    3.54  
    3.55  /* Create/destroy per-domain grant table context. */
    3.56  int grant_table_create(
     4.1 --- a/xen/include/xen/sched.h	Fri Apr 14 14:40:30 2006 +0100
     4.2 +++ b/xen/include/xen/sched.h	Fri Apr 14 14:54:46 2006 +0100
     4.3 @@ -125,7 +125,7 @@ struct domain
     4.4      struct evtchn   *evtchn[NR_EVTCHN_BUCKETS];
     4.5      spinlock_t       evtchn_lock;
     4.6  
     4.7 -    grant_table_t   *grant_table;
     4.8 +    struct grant_table *grant_table;
     4.9  
    4.10      /*
    4.11       * Interrupt to event-channel mappings. Updates should be protected by the